|
If you can't view the Datasheet, Please click here to try to view without PDF Reader . |
|
Datasheet File OCR Text: |
8 bit microcontroller tlcs-870/c series TMP86CP27AFG
page 2 TMP86CP27AFG the information contained herein is su bject to change without notice. 021023 _ d toshiba is continually working to improve the qual ity and reliability of its products. nevertheless, semiconductor devices in general can malfunction or fa il due to their inherent electrical sensitivity and vulnerability to physical stress. it is the responsibility of the buyer, when utilizing toshiba products , to comply with the standards of safety in making a safe design for the entire system, and to avoid situations in which a malfunction or failure of such toshiba products could cause loss of human life, bodily injury or damage to property. in developing your designs, please ensure that to shiba products are used within specified operating ranges as set forth in the most re cent toshiba products specifications. also, please keep in mind the precautio ns and conditions set forth in the ? handling guide for semiconductor devices, ? or ? toshiba semiconductor reliability handbook ? etc. 021023_a the toshiba products listed in this document are inte nded for usage in general electronics applications (computer, personal equipment, office equipment, measuring equipment, industrial robotics, domestic appliances, etc.). these toshiba products are neither intended nor warranted for usage in equipment that requires extraordinarily high quality and/or reliability or a malfunction or failure of which may cause loss of human life or bodily injury ( ? unintended usage ? ). unintended usage include atomic energy control instruments, airplane or spaceship instruments, tr ansportation instruments, traffic signal instruments, combustion control instruments, medical instrument s, all types of safety devices, etc. unintended usage of toshiba products listed in this document shall be made at the customer's own risk. 021023_b the products described in this document shall not be used or embedded to any downstream products of which manufacture, use and/or sale are prohib ited under any applicable laws and regulations. 060106_q the information contained he rein is presented only as a guide for the applications of our products. no responsibility is assumed by tosh iba for any infringements of patents or other rights of the third parties which may result from its use. no license is granted by implication or otherwise under any patent or patent rights of toshiba or others. 021023_c the products described in this document may include products subject to the foreign exchange and foreign trade laws. 021023_f for a discussion of how the reliability of microcontro llers can be predicted, please refer to section 1.3 of the chapter entitled quality and reli ability assurance/hand ling precautions. 030619_s ? 2006 toshiba corporation all rights reserved revision history date revision 2006/9/6 1 first release 2006/9/12 2 contents revised 2006/12/18 3 contents revised i table of contents TMP86CP27AFG 1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 pin assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.4 pin names and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2. operational description 2.1 cpu core functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.1.1 memory address map ............................................................................................................................... 9 2.1.2 program memory (maskrom) .................................................................................................................. 9 2.1.3 data memory (ram) ............................................................................................................................... 10 2.2 system clock controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2.2.1 clock generator ............................................................................................................................... ....... 10 2.2.2 timing generator ............................................................................................................................... ..... 12 2.2.2.1 configuration of timing generator 2.2.2.2 machine cycle 2.2.3 operation mode control circuit .............................................................................................................. 13 2.2.3.1 single-clock mode 2.2.3.2 dual-clock mode 2.2.3.3 stop mode 2.2.4 operating mode control ......................................................................................................................... 18 2.2.4.1 stop mode 2.2.4.2 idle1/2 mode and sleep1/2 mode 2.2.4.3 idle0 and sleep0 modes (idle0, sleep0) 2.2.4.4 slow mode 2.3 reset circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 2.3.1 external reset input ............................................................................................................................... 31 2.3.2 address trap reset ............................................................................................................................... ... 32 2.3.3 watchdog timer reset .............................................................................................................................. 32 2.3.4 system clock reset ............................................................................................................................... ... 32 3. interrupt control circuit 3.1 interrupt latches (il19 to il2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 3.2 interrupt enable register (eir) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 3.2.1 interrupt master enable flag (imf) .......................................................................................................... 36 3.2.2 individual interrupt enable flags (ef19 to ef4) ...................................................................................... 37 note 3: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 3.3 interrupt sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 3.3.1 interrupt acceptance processing is packaged as follows. ....................................................................... 39 3.3.2 saving/restoring general-purpose registers ............................................................................................ 40 3.3.2.1 using push and pop instructions 3.3.2.2 using data transfer instructions 3.3.3 interrupt return ............................................................................................................................... ......... 41 3.4 software interrupt (intsw) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 3.4.1 address error detection .......................................................................................................................... 42 3.4.2 debugging ............................................................................................................................... ............... 42 ii 3.5 undefined instruction interrupt (intundef) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 3.6 address trap interrupt (intatrap) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 3.7 external interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 4. special function r egister (sfr) 4.1 sfr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 4.2 dbr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 5. i/o ports 5.1 port p0 (p07 to p00) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 5.2 port p1 (p17 to p10) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 5.3 port p2 (p22 to p20) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 5.4 port p3 (p37 to p30) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 5.5 port p4 (p43 to p40) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 5.6 port p5 (p57 to p50) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 5.7 port p6 (p67 to p60) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 5.8 port p7 (p77 to p70) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 6. time base timer (tbt) 6.1 time base timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 6.1.1 configuration ............................................................................................................................... ........... 67 6.1.2 control ............................................................................................................................... ..................... 67 6.1.3 function ............................................................................................................................... ................... 68 6.2 divider output (dvo) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 6.2.1 configuration ............................................................................................................................... ........... 69 6.2.2 control ............................................................................................................................... ..................... 69 7. watchdog timer (wdt) 7.1 watchdog timer configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 7.2 watchdog timer control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 7.2.1 malfunction detection methods using the watchdog timer ................................................................... 72 7.2.2 watchdog timer enable ......................................................................................................................... 73 7.2.3 watchdog timer disable ........................................................................................................................ 74 7.2.4 watchdog timer interrupt (intwdt) ...................................................................................................... 74 7.2.5 watchdog timer reset ........................................................................................................................... 75 7.3 address trap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 7.3.1 selection of address trap in internal ram (atas) ................................................................................ 76 7.3.2 selection of operation at address trap (atout) .................................................................................. 76 7.3.3 address trap interrupt (intatrap) ....................................................................................................... 76 7.3.4 address trap reset ............................................................................................................................... . 77 8. 10-bit timer/counter (tc7) 8.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 8.2 control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 iii 8.3 configuring control and data registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 8.4 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 8.4.1 programmable pulse generator output (ppg output) ............................................................................. 84 8.4.1.1 50% duty mode 8.4.1.2 variable duty mode 8.4.1.3 ppg1/ppg2 independent mode 8.4.2 starting a count ............................................................................................................................... ........ 88 8.4.2.1 command start and capture mode 8.4.2.2 command start and trigger start mode 8.4.2.3 trigger start mode 8.4.2.4 trigger capture mode (cstc = 00) 8.4.2.5 trigger start/stop acceptance mode 8.4.3 configuring how the timer stops ............................................................................................................. 95 8.4.3.1 counting stopped with the outputs initialized 8.4.3.2 counting stopped with the outputs maintained 8.4.3.3 counting stopped with the outputs initialized at the end of the period 8.4.4 one-time/continuous output mode .......................................................................................................... 95 8.4.4.1 one-time output mode 8.4.4.2 continuous output mode 8.4.5 ppg output control (initial value/out put logic, enabling/disabling output) ............................................... 97 8.4.5.1 specifying initial values and output logic for ppg outputs 8.4.5.2 enabling or disabling ppg outputs 8.4.5.3 using the tc7 as a normal timer/counter 8.4.6 eliminating noise from the tc7 pin input ................................................................................................ 97 8.4.7 interrupts ............................................................................................................................... .................. 99 8.4.7.1 inttc7t (trigger start interrupt) 8.4.7.2 inttc7p (period interrupt) 8.4.7.3 intemg (emergency output stop interrupt) 8.4.8 emergency ppg output stop feature .................................................................................................... 100 8.4.8.1 enabling/disabling input on the emg pin 8.4.8.2 monitoring the emergency ppg output stop state 8.4.8.3 emg interrupt 8.4.8.4 canceling the emergency ppg output stop state 8.4.8.5 restarting the timer after canceling the emergency ppg output stop state 8.4.8.6 response time between emg pin input and ppg outputs being initialized 8.4.9 tc7 operation and microcontroller operating mode ............................................................................. 102 9. 8-bit timercounter (tc3, tc4) 9.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 9.2 timercounter control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 9.3 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 9.3.1 8-bit timer mode (tc3 and 4) .............................................................................................................. 109 9.3.2 8-bit event counter mode (tc3, 4) ...................................................................................................... 110 9.3.3 8-bit programmable divider ou tput (pdo) mode (tc3, 4) ................................................................... 110 9.3.4 8-bit pulse width modulation (pwm) output mode (tc3, 4) ................................................................ 113 9.3.5 16-bit timer mode (tc3 and 4) ............................................................................................................ 115 9.3.6 16-bit event counter mode (tc3 and 4) .............................................................................................. 116 9.3.7 16-bit pulse width modulation (pwm) output mode (tc3 and 4) ........................................................ 116 9.3.8 16-bit programmable pulse generate (ppg) output mode (tc3 and 4) ............................................. 119 9.3.9 warm-up counter mode ....................................................................................................................... 121 9.3.9.1 low-frequency warm-up counter mode (normal1 normal2 slow2 slow1) 9.3.9.2 high-frequency warm-up counter mode (slow1 slow2 normal2 normal1) 10. real-time clock 10.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 10.2 control of the rtc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 10.3 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 iv 11. asynchronous serial interface (uart ) 11.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 11.2 control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 11.3 transfer data format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 11.4 transfer rate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 11.5 data sampling method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 11.6 stop bit length . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 11.7 parity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 11.8 transmit/receive operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 11.8.1 data transmit operation .................................................................................................................... 130 11.8.2 data receive operation ..................................................................................................................... 130 11.9 status flag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 11.9.1 parity error ............................................................................................................................... ........... 131 11.9.2 framing error ............................................................................................................................... ....... 131 11.9.3 overrun error ............................................................................................................................... ....... 131 11.9.4 receive data buffer full ..................................................................................................................... 132 11.9.5 transmit data buffer empty ............................................................................................................... 132 11.9.6 transmit end flag .............................................................................................................................. 133 12. synchronous serial interface (sio) 12.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 12.2 control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 12.3 serial clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 12.3.1 clock source ............................................................................................................................... ........ 138 12.3.1.1 internal clock 12.3.1.2 external clock 12.3.2 shift edge ............................................................................................................................... ............. 139 12.3.2.1 leading edge 12.3.2.2 trailing edge 12.4 number of bits to transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 12.5 number of words to transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 12.6 transfer mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 12.6.1 4-bit and 8-bit transfer modes ............................................................................................................. 140 12.6.2 4-bit and 8-bit receive modes ............................................................................................................. 142 12.6.3 8-bit transfer / receive mode ............................................................................................................... 143 13. 10-bit ad converter (adc) 13.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 13.2 register configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 13.3 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 13.3.1 software start mode ........................................................................................................................... 151 13.3.2 repeat mode ............................................................................................................................... ....... 151 13.3.3 register setting ............................................................................................................................... . 152 13.4 stop/slow modes during ad conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 13.5 analog input voltage and ad conversion result . . . . . . . . . . . . . . . . . . . . . . . 154 13.6 precautions about ad converter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 13.6.1 restrictions for ad conversion interrupt (intadc) usage ................................................................. 155 13.6.2 analog input pin voltage range ........................................................................................................... 155 13.6.3 analog input shared pins .................................................................................................................... 155 13.6.4 noise countermeasure ....................................................................................................................... 155 v 14. key-on wakeup (kwu) 14.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 14.2 control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 14.3 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 15. lcd driver 15.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 15.2 control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 15.2.1 lcd driving methods .......................................................................................................................... 161 15.2.2 frame frequency ............................................................................................................................... .. 162 15.2.3 driving method for lcd driver ............................................................................................................ 163 15.2.3.1 when using the booster circuit (lcdcr vi page 1 060116ebp TMP86CP27AFG cmos 8-bit microcontroller ? the information contained herein is subject to change without notice. 021023_d ? toshiba is continually working to improve the quality and reli ability of its products. neverthel ess, semiconductor devices in general can malfunction or fail due to their inherent el ectrical sensitivity and vul nerability to physical stre ss. it is the responsibility of the buyer, when utilizing toshiba products, to comply with the standards of sa fety in making a safe design for the entire system, and to avoid situations in which a malfunction or failure of such toshiba products could cause loss of human life, bodily injury or damage to property. in developing your designs, pleas e ensure that toshiba products are used within specified operating ranges as set forth in the most recent toshiba products specifications. also, please keep in mind the precautions and conditions set forth in the ?handling gui de for semiconductor devices,? or ?toshiba se miconductor reliability handbook? etc. 021023_a ? the toshiba products listed in this document are intended for usage in general electronics applic ations (computer, personal eq uip- ment, office equipment, measuring equipment, industrial robotics, domestic appliances, etc.). these toshiba products are neithe r intended nor warranted for usage in equipment that requires extr aordinarily high quality and/or re liability or a malfunctionor failure of which may cause loss of human life or bod ily injury (?unintended usage?). unintended us age include atomic energy control instru ments, airplane or spaceship instruments, transporta tion instruments, traffic signal instrume nts, combustion control instruments, medi cal instru- ments, all types of safety dev ices, etc. unintended usage of toshiba products li sted in this document shall be made at the cust omer's own risk. 021023_b ? the products described in this document shall not be used or embedded to any downstream products of which manufacture, use and /or sale are prohibited under any appl icable laws and regulations. 060106_q ? the information contained herein is present ed only as a guide for the applications of our products. no responsibility is assum ed by toshiba for any infringements of patents or other rights of the th ird parties which may result from its use. no license is gran ted by impli- cation or otherwise under any patent or patent rights of toshiba or others. 021023_c ? the products described in this document are subjec t to the foreign exchange and foreign trade laws. 021023_e ? for a discussion of how the reliability of microcontrollers c an be predicted, please refer to section 1.3 of the chapter entit led quality and reliability assurance/h andling precautions. 030619_s TMP86CP27AFG 1.1 features 1. 8-bit single chip microcomputer tlcs-870/c series - instruction execution time : 0.25 s (at 16 mhz) 122 s (at 32.768 khz) - 132 types & 731 basic instructions 2. 20interrupt sources (external : 7 internal : 13) 3. input / output ports (55 pins) large current output: 8pins (typ. 20ma), led direct drive 4. prescaler - time base timer - divider output function 5. watchdog timer 6. 10-bit timer counter: 1ch (2 output pins) 2ports output ppg (programmed pulse generator) 50%duty output mode variable duty output mode external-triggered start and stop emargency stop pin 7. 8-bit timer counter : 2 ch - timer, event counter, programmable divider output (pdo), product no. rom (maskrom) ram package flash mcu emulation chip TMP86CP27AFG 49152 bytes 1024 bytes p-qfp80-1420-0.80b tmp86fs27fg tmp86c927xb page 2 1.1 features TMP86CP27AFG pulse width modulation (pwm) output, programmable pulse generation (ppg) modes 8. 8-bit uart : 1 ch 9. 8-bit sio: 1 ch 10. 10-bit successive approximation type ad converter - analog input: 8 ch 11. key-on wakeup : 4 ch 12. lcd driver/controller built-in voltage booster for lcd driver with display memory lcd direct drive capability (max 40 seg 4 com) 1/4,1/3,1/2duties or static drive are programmably selectable 13. clock operation single clock mode dual clock mode 14. low power consumption operation stop mode: oscillation stops. (battery/capacitor back-up.) slow1 mode: low power consumption operation usin g low-frequency clock.(high-frequency clock stop.) slow2 mode: low power consumption operation usin g low-frequency clock.(high-frequency clock oscillate.) idle0 mode: cpu stops, and only the time-based-tim er(tbt) on peripherals operate using high fre- quency clock. release by falling edge of th e source clock which is set by tbtcr page 3 TMP86CP27AFG 1.2 pin assignment figure 1-1 pin assignment vss xout test vdd (xtin) p21 (xtout) p22 reset ( int5 / stop ) p20 avdd (stop5/ain0) p60 (ain2) p62 (ain1) p61 ( int0 /ain3) p63 (stop2/ain4) p64 (stop3/ain5) p65 (stop4/ain6) p66 (ain7) p67 (rxd0/seg39) p00 (txd0/seg38) p01 (int3/seg35) p04 (int2/seg36) p03 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 p05(seg34/si0) p07(seg32/ sck0 ) p10(seg31) p12(seg29) p11(seg30) p54 (seg19) p53 (seg20) p52 (seg21) p51 (seg22) p50 (seg23) p17 (seg24) p16 (seg25) p15 (seg26) p14 (seg27) p13 (seg28) p06(seg33/so0) p76 (seg9) p75 (seg10) p74 (seg11) p73 (seg12) p72 (seg13) p71 (seg14) p70 (seg15) p57 (seg16) p56 (seg17) p55 (seg18) com1 c0 com3 com2 com0 seg0 seg1 seg2 seg3 seg4 seg5 seg6 seg7 p77 (seg8) (int1/seg37) p02 varef xin c1 v1 v2 v3 (so1) p41 ( sck1 ) p42 (txd1) p43 ( dvo ) p30 (tc3/ pdo3/pwm3 ) p31 (tc4/ pdo4/pwm4/ppg4 ) p32 ( emg ) p33 (tc7) p34 (ppg1) p35 (ppg2) p36 (rxd1) p37 (si1) p40 page 4 1.3 block diagram TMP86CP27AFG 1.3 block diagram figure 1-2 block diagram page 5 TMP86CP27AFG 1.4 pin names and functions table 1-1 pin names and functions(1/4) pin name pin number input/output functions p07 seg32 sck0 27 io o io port07 lcd segment output 32 serial clock i/o 0 p06 seg33 so0 26 io o o port06 lcd segment output 33 serial data output 0 p05 seg34 si0 25 io o i port05 lcd segment output 34 serial data input 0 p04 seg35 int3 24 io o i port04 lcd segment output 35 external interrupt 3 input p03 seg36 int2 23 io o i port03 lcd segment output 36 external interrupt 2 input p02 seg37 int1 22 io o i port02 lcd segment output 37 external interrupt 1 input p01 seg38 txd0 21 io o o port01 lcd segment output 38 uart data output 0 p00 seg39 rxd0 20 io o i port00 lcd segment output 39 uart data input 0 p17 seg24 35 io o port17 lcd segment output 24 p16 seg25 34 io o port16 lcd segment output 25 p15 seg26 33 io o port15 lcd segment output 26 p14 seg27 32 io o port14 lcd segment output 27 p13 seg28 31 io o port13 lcd segment output 28 p12 seg29 30 io o port12 lcd segment output 29 p11 seg30 29 io o port11 lcd segment output 30 p10 seg31 28 io o port10 lcd segment output 31 p22 xtout 7 io o port22 resonator connecting pins(32.768 khz) for inputting external clock p21 xtin 6 io i port21 resonator connecting pins(32.768 khz) for inputting external clock page 6 1.4 pin names and functions TMP86CP27AFG p20 stop int5 9 io i i port20 stop mode release signal input external interrupt 5 input p37 rxd1 80 io i port37 uart data input 1 p36 ppg2 79 io o port36 timer counter 7 ppg2 output p35 ppg1 78 io o port35 timer counter 7 ppg1 output p34 tc7 77 io i port34 timer counter 7 input p33 emg 76 io i port33 timer counter 7 emergency stop input p32 pdo4/pwm4/ppg4 tc4 75 io o i port32 pdo4/pwm4/ppg4 output tc4 input p31 pdo3/pwm3 tc3 74 io o i port31 pdo3/pwm3 output tc3 input p30 dvo 73 io o port30 divider output p43 txd1 72 io o port43 uart data output 1 p42 sck1 71 io io port42 serial clock i/o 1 p41 so1 70 io o port41 serial data output 1 p40 si1 69 io i port40 serial data input 1 p57 seg16 43 io o port57 lcd segment output 16 p56 seg17 42 io o port56 lcd segment output 17 p55 seg18 41 io o port55 lcd segment output 18 p54 seg19 40 io o port54 lcd segment output 19 p53 seg20 39 io o port53 lcd segment output 20 p52 seg21 38 io o port52 lcd segment output 21 p51 seg22 37 io o port51 lcd segment output 22 p50 seg23 36 io o port50 lcd segment output 23 p67 ain7 19 io i port67 analog input7 table 1-1 pin names and functions(2/4) pin name pin number input/output functions page 7 TMP86CP27AFG p66 ain6 stop4 18 io i i port66 analog input6 stop4 input p65 ain5 stop3 17 io i i port65 analog input5 stop3 input p64 ain4 stop2 16 io i i port64 analog input4 stop2 input p63 ain3 int0 15 io i i port63 analog input3 external interrupt 0 input p62 ain2 14 io i port62 analog input2 p61 ain1 13 io i port61 analog input1 p60 ain0 stop5 12 io i i port60 analog input0 stop5 input p77 seg8 51 io o port77 lcd segment output 8 p76 seg9 50 io o port76 lcd segment output 9 p75 seg10 49 io o port75 lcd segment output 10 p74 seg11 48 io o port74 lcd segment output 11 p73 seg12 47 io o port73 lcd segment output 12 p72 seg13 46 io o port72 lcd segment output 13 p71 seg14 45 io o port71 lcd segment output 14 p70 seg15 44 io o port70 lcd segment output 15 seg7 52 o lcd segment output 7 seg6 53 o lcd segment output 6 seg5 54 o lcd segment output 5 seg4 55 o lcd segment output 4 seg3 56 o lcd segment output 3 seg2 57 o lcd segment output 2 seg1 58 o lcd segment output 1 seg0 59 o lcd segment output 0 com3 63 o lcd common output 3 com2 62 o lcd common output 2 table 1-1 pin names and functions(3/4) pin name pin number input/output functions page 8 1.4 pin names and functions TMP86CP27AFG com1 61 o lcd common output 1 com0 60 o lcd common output 0 v3 68 i lcd voltage booster pin v2 67 i lcd voltage booster pin v1 66 i lcd voltage booster pin c1 65 i lcd voltage booster pin c0 64 i lcd voltage booster pin xin 2 i resonator connecting pins for high-frequency clock xout 3 o resonator connecting pins for high-frequency clock reset 8 i reset signal test 4 i test pin for out-going test. normally, be fixed to low. varef 11 i analog base voltage input pin for a/d conversion avdd 10 i analog power supply vdd 5 i +5v vss 1 i 0(gnd) table 1-1 pin names and functions(4/4) pin name pin number input/output functions page 9 TMP86CP27AFG 2. operational description 2.1 cpu core functions the cpu core consists of a cpu, a system cl ock controller, and an interrupt controller. this section provides a description of the cpu core, the program memory, the data memory, and the reset circuit. 2.1.1 memory address map the TMP86CP27AFG memory is composed maskrom, ram, dbr(data buffer register) and sfr(special function register). they are all mapped in 64-kbyte address space. figure 2-1 shows the TMP86CP27AFG memory address map. figure 2-1 memory address map 2.1.2 program memory (maskrom) the TMP86CP27AFG has a 49152 bytes (address 4000h to ffffh) of program memory (maskrom ). sfr 0000 h 64 bytes sfr: ram: special function register includes: i/o ports peripheral control registers peripheral status registers system control registers program status word random access memory includes: data memory stack 003f h ram 0040 h 1024 bytes 043f h dbr 0f80 h 128 bytes dbr: data buffer register includes: peripheral control registers peripheral status registers lcd display memory 0fff h 4000 h maskrom: program memory maskrom 49152 bytes ffb0 h vector table for interrupts (16 bytes) ffbf h ffc0 h vector table for vector call instructions (32 bytes) ffdf h ffe0 h vector table for interrupts (32 bytes) ffff h page 10 2. operational description 2.2 system clock controller TMP86CP27AFG 2.1.3 data memory (ram) the TMP86CP27AFG has 1024bytes (address 0040h to 043fh) of internal ram. the first 192 bytes (0040h to 00ffh) of the internal ra m are located in the direct area; inst ructions with shorten operations are available against such an area. the data memory contents become un stable when the power supply is turned on; therefore, the data memory should be initialized by an initialization routine. 2.2 system clock controller the system clock controller consists of a clock generator, a timing generator, and a standby controller. figure 2-2 syst em colck control 2.2.1 clock generator the clock generator generates the basic clock which pr ovides the system clocks supplied to the cpu core and peripheral hardware. it contains two oscillation ci rcuits: one for the high-frequency clock and one for the low-frequency clock. power consumption can be reduced by switching of the standby controller to low-power operation based on the low-frequency clock. the high-frequency (fc) clock and low-frequency (fs) clock can easily be obtained by connecting a resonator between the xin/xout and xtin/xtout pins respectively. clock input from an exte rnal oscillator is also possible. in this case, external clock is applied to xin/xtin pin with xout/xtout pin not connected. example :clears ram to ?00h?. (TMP86CP27AFG) ld hl, 0040h ; start address setup ld a, h ; initial value (00h) setup ld bc, 03ffh sramclr: ld (hl), a inc hl dec bc jrs f, sramclr tbtcr syscr2 syscr1 xin xout xtin xtout fc 0036 h 0038 h 0039 h fs timing generator control register timing generator standby controller system clocks clock generator control high-frequency clock oscillator low-frequency clock oscillator clock generator system control registers page 11 TMP86CP27AFG figure 2-3 examples of resonator connection note:the function to monitor the basic clock directly at external is not provided for hardware, however, with dis- abling all interrupts and watchdog timers, the oscillation frequency can be adjusted by monitoring the pulse which the fixed frequency is outputted to the port by the program. the system to require the adjustment of the oscilla tion frequency should create the program for the adjust- ment in advance. xout xin (open) xout xin xtout xtin (open) xtout xtin (a) crystal/ceramic resonator (b) external oscillator (c) crystal (d) external oscillator high-frequency clock low-frequency clock page 12 2. operational description 2.2 system clock controller TMP86CP27AFG 2.2.2 timing generator the timing generator generates the various system cloc ks supplied to the cpu core and peripheral hardware from the basic clock (fc or fs). the timing generator provides the following functions. 1. generation of main system clock 2. generation of divider output ( dvo ) pulses 3. generation of source clocks for time base timer 4. generation of source clocks for watchdog timer 5. generation of internal source clocks for timer/counters 6. generation of warm-up clocks for releasing stop mode 7. lcd 2.2.2.1 configuration of timing generator the timing generator consists of a 2-stage prescaler, a 21-stage divider, a main system clock generator, and machine cycle counters. an input clock to the 7th stage of the divider depends on the operating mode, syscr2 page 13 TMP86CP27AFG note 1: in single clock mode, do not set dv7ck to ?1?. note 2: do not set ?1? on dv7ck while the low-frequency clock is not operated stably. note 3: fc: high-frequency clock [hz], fs : low-frequency clock [hz], *: don?t care note 4: in slow1/2 and sleep1/2 modes, the dv7ck setting is ineffective, and fs is input to the 7th stage of the divider. note 5: when stop mode is entered from normal1/2 mode, the dv 7ck setting is ineffective during the warm-up period after release of stop mode, and the 6th stage of the divider is input to the 7th stage during this period. 2.2.2.2 machine cycle instruction execution and peripheral hardware operat ion are synchronized with the main system clock. the minimum instruction execution uni t is called an ?machine cycle?. th ere are a total of 10 different types of instructions for the tlcs-870/c series: ra nging from 1-cycle instructions which require one machine cycle for execution to 10-cyc le instructions which require 10 machine cycles fo r execution. a machine cycle consists of 4 states (s0 to s3), and each state consists of one main system clock. figure 2-5 machine cycle 2.2.3 operation mode control circuit the operation mode control circuit starts and stops th e oscillation circuits for the high-frequency and low- frequency clocks, and switches the main system clock. there are three operating modes: single clock mode, dual clock mode and stop mode. these modes are cont rolled by the system cont rol registers (syscr1 and syscr2). figure 2-6 shows the operating mode transition diagram. 2.2.3.1 single-clock mode only the oscillation circuit for the high-frequenc y clock is used, and p21 (xtin) and p22 (xtout) pins are used as input/output ports . the main-system clock is obtained from the high-frequency clock. in the single-clock mode, the machine cycle time is 4/fc [s]. (1) normal1 mode in this mode, both the cpu core and on-chip pe ripherals operate using the high-frequency clock. the TMP86CP27AFG is placed in this mode after reset. timing generator control register tbtcr (0036h) 76543210 (dvoen) (dvock) dv7ck (tbten) (tbtck) (initial value: 0000 0000) dv7ck selection of input to the 7th stage of the divider 0: fc/2 8 [hz] 1: fs r/w main system clock state machine cycle s3 s2 s1 s0 s3 s2 s1 s0 1/fc or 1/fs [s] page 14 2. operational description 2.2 system clock controller TMP86CP27AFG (2) idle1 mode in this mode, the internal oscillation circuit remains active. the cpu and the watchdog timer are halted; however on-chip peripherals remain active (operate using the high-frequency clock). idle1 mode is started by syscr2 page 15 TMP86CP27AFG switching back and forth between slow1 and slow2 modes are performed by syscr2 page 16 2. operational description 2.2 system clock controller TMP86CP27AFG note 1: normal1 and normal2 modes are generically called no rmal; slow1 and slow2 are called slow; idle0, idle1 and idle2 are called idle; sleep0, sleep1 and sleep2 are called sleep. note 2: the mode is released by fa lling edge of tbtcr page 17 TMP86CP27AFG note 1: always set retm to ?0? when transiting from normal mode to stop mode. always set retm to ?1? when transiting from slow mode to stop mode. note 2: when stop mode is released with reset pin input, a return is made to normal1 regardless of the retm contents. note 3: fc: high-frequency clock [hz], fs : low-frequency clock [hz], *; don?t care note 4: bits 1 and 0 in syscr1 are read as undefined data when a read instruction is executed. note 5: as the hardware becomes stop mode under outen = ?0?, input value is fixed to ?0?; therefore it may cause external interrupt request on account of falling edge. note 6: when the key-on wakeup is used, relm should be set to "1". note 7: port p20 is used as stop pin. therefore, when stop mode is started, outen does not affect to p20, and p20 becomes high-z mode. note 8: the warmig-up time should be set correctly for using oscillator. note 1: a reset is applied if both xen and xten are cleared to ?0?, xen is cleared to ?0? when sysck = ?0?, or xten is cleared to ?0? when sysck = ?1?. note 2: *: don?t care, tg: timing generator, *; don?t care note 3: bits 3, 1 and 0 in syscr2 are always read as undefined value. note 4: do not set idle and tghalt to ?1? simultaneously. note 5: because returning from idle0/sleep0 to normal1/slow 1 is executed by the asynchronous internal clock, the period of idle0/sleep0 mode might be shorter than the period setting by tbtcr page 18 2. operational description 2.2 system clock controller TMP86CP27AFG 2.2.4 operating mode control 2.2.4.1 stop mode stop mode is controlled by the system control register 1, the stop pin input and key-on wakeup input (stop5 to stop2) which is controlled by the stop mode release control register (stopcr). the stop pin is also used both as a port p20 and an int5 (external interrupt input 5) pin. stop mode is started by setting syscr1 page 19 TMP86CP27AFG figure 2-7 level-s ensitive release mode note 1: even if the stop pin input is low after warm-up start, the stop mode is not restarted. note 2: in this case of changing to the level-s ensitive mode from the edge-s ensitive mode, the release mode is not switched until a rising edge of the stop pin input is detected. (2) edge-sensitive release mode (relm = ?0?) in this mode, stop mode is released by a rising edge of the stop pin input. this is used in appli- cations where a relatively short pr ogram is executed repeat edly at periodic intervals. this periodic signal (for example, a clock from a low-power consumption oscillator) is input to the stop pin. in the edge-sensitive release mode, stop mode is started even when the stop pin input is high level. do not use any stop5 to stop2 pin input for releasing stop mode in edge-sensitive release mode. figure 2-8 edge-sensitive release mode example 2 :starting stop mode from normal mode with an int5 interrupt. pint5: test (p2prd). 0 ; to reject noise, stop mode does not start if jrs f, sint5 port p20 is at high ld (syscr1), 01010000b ; sets up the level-sensitive release mode. di ; imf 0 set (syscr1). 7 ; starts stop mode sint5: reti example :starting stop mode from normal mode di ; imf 0 ld (syscr1), 10010000b ; starts after specified to the edge-sensitive release mode v ih normal operation warm up stop operation confirm by program that the stop pin input is low and start stop mode. always released if the stop pin input is high. stop pin xout pin stop mode is released by the hardware. normal operation normal operation normal operation v ih stop mode is released by the hardware at the rising edge of stop pin input. warm up stop mode started by the program. stop operation stop operation stop pin xout pin page 20 2. operational description 2.2 system clock controller TMP86CP27AFG stop mode is released by the following sequence. 1. in the dual-clock mode, when returning to normal2, both the high-frequency and low- frequency clock oscillators are turned on; when returning to slow1 mode, only the low- frequency clock oscillator is turned on. in the single-clock mode, only the high-frequency clock oscillator is turned on. 2. a warm-up period is inserted to allow oscillation time to stabilize. during warm up, all internal operations remain halted. four differ ent warm-up times can be selected with the syscr1 page 21 TMP86CP27AFG figure 2-9 stop mode start/release instruction address a + 4 0 instruction address a + 3 turn on turn on warm up 0 n halt set (syscr1). 7 turn off (a) stop mode start (example: start with set (syscr1). 7 instruction located at address a) a + 6 a + 5 a + 4 a + 3 a + 2 n + 2 n + 3 n + 4 a + 3 n + 1 instruction address a + 2 2 1 0 3 (b) stop mode release count up turn off halt oscillator circuit program counter instruction execution divider main system clock oscillator circuit stop pin input program counter instruction execution divider main system clock page 22 2. operational description 2.2 system clock controller TMP86CP27AFG 2.2.4.2 idle1/2 mode and sleep1/2 mode idle1/2 and sleep1/2 modes are controlled by the system control register 2 (syscr2) and maskable interrupts. the following status is maintained during these modes. 1. operation of the cpu and watchdog timer (wdt) is halted. on-chip peripherals continue to operate. 2. the data memory, cpu registers, program status word and port output latches are all held in the status in effect before these modes were entered. 3. the program counter holds the address 2 ahead of th e instruction which starts these modes. figure 2-10 idle1/ 2 and sleep1/2 modes reset reset input ?0? ?1? (interrupt release mode) yes no no cpu and wdt are halted interrupt request imf interrupt processing normal release mode yes starting idle1/2 and sleep1/2 modes by instruction execution of the instruc- tion which follows the idle1/2 and sleep1/2 modes start instruction page 23 TMP86CP27AFG ? start the idle1/2 and sleep1/2 modes after imf is set to "0", set the individual inte rrupt enable flag (ef) which releases idle1/2 and sleep1/2 modes. to start idle1/2 and sl eep1/2 modes, set syscr2 page 24 2. operational description 2.2 system clock controller TMP86CP27AFG figure 2-11 idle1/2 and sleep1/2 modes start/release halt halt halt halt operate instruction address a + 2 a + 3 a + 2 a + 4 a + 3 a + 3 halt set (syscr2). 4 operate operate operate acceptance of interrupt ?r:w normal release mode ?s:w interrupt release mode main system clock interrupt request program counter instruction execution watchdog timer main system clock interrupt request program counter instruction execution watchdog timer main system clock interrupt request program counter instruction execution watchdog timer (a) idle1/2 and sleep1/2 modes start (example: star ting with the set instruction located at address a) (b) idle1/2 and sleep1/2 modes release page 25 TMP86CP27AFG 2.2.4.3 idle0 and sleep0 modes (idle0, sleep0) idle0 and sleep0 modes are controlled by the system control register 2 (syscr2) and the time base timer control register (tbtcr). the following stat us is maintained during idle0 and sleep0 modes. 1. timing generator stops feeding clock to peripherals except tbt. 2. the data memory, cpu registers, program status word and port output latches are all held in the status in effect before idle0 and sleep0 modes were entered. 3. the program counter holds the address 2 ahead of the instru ction which starts idle0 and sleep0 modes. note: before starting idle0 or sleep0 mode, be sure to stop (disable) peripherals. figure 2-12 idle 0 and sleep0 modes yes (normal release mode) yes (interrupt release mode) no yes reset input cpu and wdt are halted reset tbt source clock falling edge tbtcr page 26 2. operational description 2.2 system clock controller TMP86CP27AFG ? start the idle0 and sleep0 modes stop (disable) peripherals such as a timer counter. to start idle0 and sleep0 modes, set syscr2 page 27 TMP86CP27AFG figure 2-13 idle0 and slee p0 modes start/release halt halt operate instruction address a + 2 halt operate set (syscr2). 2 halt operate acceptance of interrupt halt ?r:w normal release mode ?s:w interrupt release mode main system clock interrupt request program counter instruction execution watchdog timer main system clock tbt clock tbt clock program counter instruction execution watchdog timer main system clock program counter instruction execution watchdog timer a + 3 a + 2 a + 4 a + 3 a + 3 (a) idle0 and sleep0 modes start (example: starting with the set instruction located at address a (b) idle and sleep0 modes release page 28 2. operational description 2.2 system clock controller TMP86CP27AFG 2.2.4.4 slow mode slow mode is controlled by the sy stem control register 2 (syscr2). the following is the methods to switch the mode with the warm-up counter. (1) switching from normal2 mode to slow1 mode first, set syscr2 page 29 TMP86CP27AFG (2) switching from slow1 mode to normal2 mode note: after sysck is cleared to ?0?, executing the in structions is continiued by the low-frequency clock for the period synchronized with low-frequency and high-frequency clocks. first, set syscr2 page 30 2. operational description 2.2 system clock controller TMP86CP27AFG figure 2-14 switching between the normal2 and slow modes set (syscr2). 7 normal2 mode clr (syscr2). 7 set (syscr2). 5 normal2 mode turn off (a) switching to the slow mode slow1 mode slow2 mode clr (syscr2). 5 (b) switching to the normal2 mode high- frequency clock low- frequency clock main system clock instruction execution sysck xen high- frequency clock low- frequency clock main system clock instruction execution sysck xen slow1 mode warm up during slow2 mode page 31 TMP86CP27AFG 2.3 reset circuit the TMP86CP27AFG has four types of reset generation pro cedures: an external reset in put, an address trap reset, a watchdog timer reset and a system cloc k reset. of these reset, the address trap reset, the watchdog timer and the system clock reset are a malfunction re set. when the malfunction reset request is detected, reset occurs during the maximum 24/fc[s]. the malfunction reset circuit such as watchdog timer reset, address trap reset and system clock reset is not initial- ized when power is turned on. therefore, reset may occur during maximum 24/fc[s] (1.5 s at 16.0 mhz) when power is turned on. table 2-3 shows on-chip hardware initialization by reset action. 2.3.1 external reset input the reset pin contains a schmitt trigger (hysteresis) with an internal pull-up resistor. when the reset pin is held at ?l? level for at least 3 machin e cycles (12/fc [s]) wi th the power supply volt- age within the operating voltage range and oscillation stab le, a reset is applied and the internal state is initial- ized. when the reset pin input goes high, the reset operation is rele ased and the program execution starts at the vector address stored at addresses fffeh to ffffh. figure 2-15 reset circuit table 2-3 initializing internal status by reset action on-chip hardware initial value on-chip hardware initial value program counter (pc) (fffeh) prescaler and divider of timing generator 0 stack pointer (sp) not initialized general-purpose registers (w, a, b, c, d, e, h, l, ix, iy) not initialized jump status flag (jf) not initialized watchdog timer enable zero flag (zf) not initialized output latches of i/o ports refer to i/o port circuitry carry flag (cf) not initialized half carry flag (hf) not initialized sign flag (sf) not initialized overflow flag (vf) not initialized interrupt master enable flag (imf) 0 interrupt individual enable flags (ef) 0 control registers refer to each of control register interrupt latches (il) 0 lcd data buffer not initialized ram not initialized internal reset reset vdd malfunction reset output circuit watchdog timer reset address trap reset system clock reset page 32 2. operational description 2.3 reset circuit TMP86CP27AFG 2.3.2 address trap reset if the cpu should start looping for some cause such as noise and an attempt be made to fetch an instruction from the on-chip ram (when wdtcr1 page 33 TMP86CP27AFG page 34 2. operational description 2.3 reset circuit TMP86CP27AFG page 35 TMP86CP27AFG 3. interrupt control circuit the TMP86CP27AFG has a total of 20 in terrupt sources excluding reset. interru pts can be nested with priorities. four of the internal interrupt sources ar e non-maskable while the rest are maskable. interrupt sources are provided with interrupt latches (il) , which hold interrupt requests, and independent vectors. the interrupt latch is set to ?1? by th e generation of its interrupt request wh ich requests the cpu to accept its inter- rupts. interrupts are enabled or disabled by software using the interrupt master enable fl ag (imf) and in terrupt enable flag (ef). if more than one interrupts are generated simultaneously, interrup ts are accepted in order which is domi- nated by hardware. however, there are no prioritized interrupt factors among non-maskable interrupts. note 1: to use the address trap interrupt (intatrap), clear wdtcr1 page 36 3. interrupt control circuit 3.2 interrupt enable register (eir) TMP86CP27AFG the interrupt latches are located on address 002eh, 003ch and 003dh in sfr area. each latch can be cleared to "0" individually by instruction. however, il2 and il3 sh ould not be cleared to "0" by software. for clearing the interrupt latch, load instruction should be used and then il2 and il3 should be set to "1". if the read-modify-write instructions such as bit manipulation or operation instru ctions are used, interrupt re quest would be cleared inade- quately if interrupt is requested while such instructions are executed. interrupt latches are not set to ?1? by an instruction. since interrupt latches can be read, the status fo r interrupt requests can be monitored by software. note: in main program, before manipulating the interrupt enable flag (ef) or the interrupt latch (il), be sure to clear imf to "0" (disable interrupt by di instruction). then set imf new ly again as required after operating on the ef or il (enable interrupt by ei instruction) in interrupt service routine, because the imf becomes "0 " automatically, clearing imf need not execute normally on interrupt service routine. however, if using multiple inte rrupt on interrupt service routine, manipulating ef or il should be executed before setting imf="1". 3.2 interrupt enab le register (eir) the interrupt enable register (eir) enables and disables the acceptance of interrupts, except fo r the non-maskable interrupts (software interrupt, undefined instruction interr upt, address trap interrupt and watchdog interrupt). non- maskable interrupt is accepted regardless of the contents of the eir. the eir consists of an interrupt mast er enable flag (imf) and the individua l interrupt enable flags (ef). these registers are located on address 002ch, 003ah and 003bh in sfr area, and they can be read and written by an instructions (including read-modify-write instructions such as bit manipulation or operation instructions). 3.2.1 interrupt ma ster enable flag (imf) the interrupt enable register (imf ) enables and disables the acceptance of the whole maskable interrupt. while imf = ?0?, all maskable interrupts are not accepted regardless of the status on each individual interrupt enable flag (ef). by setting imf to ?1?, the interrupt becomes acceptable if the individuals are enabled. when an interrupt is accepted, imf is cleared to ?0? after the latest status on imf is stacked. thus the maskable inter- rupts which follow are disabled. by executing return interrupt instruction [reti/retn], the stacked data, which was the status before interrup t acceptance, is loaded on imf again. the imf is located on bit0 in eirl (address: 003ah in sfr), and can be read and written by an instruction. the imf is normally set and cl eared by [ei] and [di] instruction respectively. during reset, the imf is initial- ized to ?0?. example 1 :clears interrupt latches di ; imf 0 ldw (ill), 111010000011 1111b ; il12, il10 to il6 0 ei ; imf 1 example 2 :reads interrupt latchess ld wa, (ill) ; w ilh, a ill example 3 :tests interrupt latches test (ill). 7 ; if il7 = 1 then jump jr f, sset page 37 TMP86CP27AFG 3.2.2 individual interrupt enable flags (ef19 to ef4) each of these flags enables and disables the acceptan ce of its maskable interrupt . setting the corresponding bit of an individual interrupt enable flag to ?1? enables acceptan ce of its interrupt, and setting the bit to ?0? dis- ables acceptance. during reset, all the i ndividual interrupt enable flags (ef19 to ef4) ar e initialized to ?0? and all maskable interrupts are not accepted until they are set to ?1?. note:in main program, before manipulating the interrupt enable flag (ef) or the interrupt latch (il), be sure to clear imf to "0" (disable interrupt by di instruction). then set imf newly again as required after operating on the ef or il (enable interrupt by ei instruction) in interrupt service routine, because the imf become s "0" automatically, clearing imf need not execute nor- mally on interrupt service routine. however, if using mult iple interrupt on interrupt service routine, manipulat- ing ef or il should be executed before setting imf="1". example 1 :enables interrupts individually and sets imf di ; imf 0 ldw : (eirl), 1110100010100000b ; ef15 to ef13, ef11, ef7, ef5 1 note: imf should not be set. : ei ; imf 1 example 2 :c compiler description example unsigned int _io (3ah) eirl; /* 3ah shows eirl address */ _di(); eirl = 10100000b; : _ei(); page 38 3. interrupt control circuit 3.2 interrupt enable register (eir) TMP86CP27AFG note 1: to clear any one of bits il7 to il4, be sure to write "1" into il2 and il3. note 2: in main program, before manipulating the interrupt enable fl ag (ef) or the interrupt latch (il), be sure to clear imf to "0" (disable interrupt by di instruction). then set imf newly again as required after operating on the ef or il (enable interrupt by ei instruction) in interrupt service routine, because the imf becomes "0" automatically, clear ing imf need not execute normally on inter- rupt service routine. however, if using multiple interrupt on interrupt service routine, mani pulating ef or il should be exe- cuted before setting imf="1". note 3: do not clear il with read-modify-w rite instructions such as bit operations. note 1: *: don?t care note 2: do not set imf and the interrupt enable flag (ef15 to ef4) to ?1? at the same time. note 3: in main program, before manipulating the interrupt enable fl ag (ef) or the interrupt latch (il), be sure to clear imf to "0" (disable interrupt by di instruction). then set imf newly again as required after operating on the ef or il (enable interrupt by ei instruction) in interrupt service routine, because the imf becomes "0" automatically, clear ing imf need not execute normally on inter- rupt service routine. however, if using multiple interrupt on interrupt service routine, mani pulating ef or il should be exe- cuted before setting imf="1". interrupt latches (initial value: 00000000 000000**) ilh,ill (003dh, 003ch) 1514131211109876543210 il15 il14 il13 il12 il11 il10 il9 il8 il7 il6 il5 il4 il3 il2 ilh (003dh) ill (003ch) (initial value: ****0000) ile (002eh) 76543210 ???? il19 il18 il17 il16 ile (002eh) il19 to il2 interrupt latches at rd 0: no interrupt request 1: interrupt request at wr 0: clears the interrupt request 1: (interrupt latch is not set.) r/w interrupt enable registers (initial value: 00000000 0000***0) eirh,eirl (003bh, 003ah) 1514131211109876543210 ef15 ef14 ef13 ef12 ef11 ef10 ef9 ef8 ef7 ef6 ef5 ef4 imf eirh (003bh) eirl (003ah) (initial value: ****0000) eire (002ch) 76543210 ???? ef19 ef18 ef17 ef16 eire (002ch) ef19 to ef4 individual-interrupt enable flag (specified for each bit) 0: 1: disables the acceptance of each maskable interrupt. enables the acceptance of each maskable interrupt. r/w imf interrupt master enable flag 0: 1: disables the acceptance of all maskable interrupts enables the acceptance of all maskable interrupts page 39 TMP86CP27AFG 3.3 interrupt sequence an interrupt request, which raised inte rrupt latch, is held, until interrupt is accepted or interrupt latch is cleared to ?0? by resetting or an instruct ion. interrupt acceptance sequence requires 8 machine cycles (2 s @16 mhz) after the completion of the current instruction. the interrupt service task terminates upon execution of an interrupt return instruction [reti] (for maskable interrupts) or [retn] (for non-maskable interrupts). figure 3-1 shows the timing chart of interrupt acceptance processing. 3.3.1 interrupt acceptance proc essing is packaged as follows. a. the interrupt master enab le flag (imf) is cleared to ?0? in or der to disable the acceptance of any fol- lowing interrupt. b. the interrupt latch (il) for the interrupt source accepted is cleared to ?0?. c. the contents of the program coun ter (pc) and the program status word, including the interrupt master enable flag (imf), are saved (pushed) on the st ack in sequence of psw + imf, pch, pcl. mean- while, the stack pointer (s p) is decremented by 3. d. the entry address (interrupt vect or) of the corresponding interrupt service program, loaded on the vec- tor table, is transferred to the program counter. e. the instruction stored at the entry address of the inte rrupt service program is executed. note:when the contents of psw are saved on the stack, the contents of imf are also saved. note 1: a: return address entry address, b: entry address, c: address which reti instruction is stored note 2: on condition that interrupt is enabled, it takes 38/fc [s ] or 38/fs [s] at maximum (if the interrupt latch is set at the first machine cycle on 10 cycle instruction) to start interrupt acceptance processing since its interrupt latch is set. figure 3-1 timing chart of interrupt acceptance/return in terrupt instruction example: correspondence be tween vector table address for inttbt an d the entry address of the interrupt service program figure 3-2 vector table address,entry address a b a c + 1 execute instruction sp pc execute instruction n n ? 2 n - 3 n ? 2n ? 1 n ? 1 n a + 2 a + 1 c + 2 b + 3 b + 2 b + 1 a + 1 a a ? 1 execute reti instruction interrupt acceptance execute instruction interrupt service task 1-machine cycle interrupt request interrupt latch (il) imf d2h 03h d203h d204h 06h vector table address entry address 0fh vector interrupt service program fff0h fff1h page 40 3. interrupt control circuit 3.3 interrupt sequence TMP86CP27AFG a maskable interrupt is not accepted until the imf is set to ?1? even if th e maskable interrupt higher than the level of current servicing interrupt is requested. in order to utilize nested interrupt service, the imf is set to ?1? in the interrupt service program. in this case, acceptable interrupt sources are selectively en abled by the individual interrupt enable flags. to avoid overloaded nesting, clear the individual interrupt enable flag whose interrupt is currently serviced, before setting imf to ?1?. as for non-maskable interr upt, keep interrupt service shorten compared with length between interrupt requests; otherwise the status cannot be recovered as non-maskable interrupt would simply nested. 3.3.2 saving/restoring general-purpose registers during interrupt acceptance processing , the program counter (pc) and the program status word (psw, includes imf) are automati cally saved on the stack, but the accumulato r and others are not. these registers are saved by software if necessary. when multiple interrupt se rvices are nested, it is also necessary to avoid using the same data memory area for saving registers. the fo llowing methods are used to save/restore the general- purpose registers. 3.3.2.1 using push and pop instructions if only a specific register is saved or interrupts of the same source are nested , general-purpose registers can be saved/restored using the push/pop instructions. figure 3-3 save/store register using push and pop instructions 3.3.2.2 using data transfer instructions to save only a specific register wi thout nested interrupts, data tran sfer instructions are available. example :save/store register us ing push and pop instructions pintxx: push wa ; save wa register (interrupt processing) pop wa ; restore wa register reti ; return pcl pch psw at acceptance of an interrupt at execution of push instruction at execution of reti instruction at execution of pop instruction b-4 b-3 b-2 b-1 b pcl pch psw pcl pch psw sp address (example) sp sp sp a w b-5 page 41 TMP86CP27AFG figure 3-4 saving/restoring general-purpose r egisters under interrupt processing 3.3.3 interrupt return interrupt return instructions [reti]/[retn] perform as follows. as for address trap interrupt (intatrap), it is requir ed to alter stacked data for program counter (pc) to restarting address, during interrupt service program. note:if [retn] is executed with the above data unaltered, the program returns to the address trap area and intatrap occurs again.when interrupt acceptance pr ocessing has completed, stacked data for pcl and pch are located on address (sp + 1) and (sp + 2) respectively. example :save/store register us ing data transfer instructions pintxx: ld (gsava), a ; save a register (interrupt processing) ld a, (gsava) ; restore a register reti ; return [reti]/[retn] interrupt return 1. program counter (pc) and program status word (psw, includes imf) are restored from the stack. 2. stack pointer (sp) is incremented by 3. example 1 :returning from address trap interrupt (intatrap) service program pintxx: pop wa ; recover sp by 2 ld wa, return address ; push wa ; alter stacked data (interrupt processing) retn ; return interrupt acceptance interrupt service task restoring registers saving registers interrupt return saving/restoring general-purpose registers using push/pop data transfer instruction main task page 42 3. interrupt control circuit 3.4 software interrupt (intsw) TMP86CP27AFG interrupt requests are sampled during the final cycle of the instruction being executed. thus, the next inter- rupt can be accepted immediat ely after the interrupt retu rn instruction is executed. note 1: it is recommended that stack pointer be return to rate before intatrap (increment 3 times), if return inter- rupt instruction [retn] is not utilized during inte rrupt service program under intatrap (such as example 2). note 2: when the interrupt processing time is longer than the interrupt request generation time, the interrupt service task is performed but not the main task. 3.4 software interrupt (intsw) executing the swi instruction generates a software interr upt and immediately starts interrupt processing (intsw is highest prioritized interrupt). use the swi instruction only for detection of the address error or for debugging. 3.4.1 address error detection ffh is read if for some cause such as noise the cpu attempts to fetch an instruction from a non-existent memory address during single chip mode. code ffh is th e swi instruction, so a software interrupt is gener- ated and an address error is detect ed. the address error detection range can be further expanded by writing ffh to unused areas of the program memory. address trap reset is generated in case that an instruction is fetched from ram, dbr or sfr areas. 3.4.2 debugging debugging efficiency can be increased by placing the swi instruction at the software break point setting address. 3.5 undefined instruct ion interrupt (intundef) taking code which is not defined as authorized instru ction for instruction causes intundef. intundef is gen- erated when the cpu fetches such a co de and tries to execute it. intundef is accepted even if non-maskable inter- rupt is in process. contemporary process is broken and intundef interrupt process starts, soon after it is requested. note: the undefined instruction interrupt (intundef) forces cpu to jump into vector address, as software interrupt (swi) does. 3.6 address trap interrupt (intatrap) fetching instruction from unauthorized area for instructio ns (address trapped area) cause s reset output or address trap interrupt (intatrap). intatrap is accepted even if non-maskable interrupt is in process. contemporary pro- cess is broken and intatrap interrupt pro cess starts, soon afte r it is requested. note: the operating mode under address trapped, whether to be reset output or interrupt processing, is selected on watchdog timer control register (wdtcr). example 2 :restarting without returning interrupt (in this case, psw (includes imf) befo re interrupt acceptance is discarded.) pintxx: inc sp ; recover sp by 3 inc sp ; inc sp ; (interrupt processing) ld eirl, data ; set imf to ?1? or clear it to ?0? jp restart address ; jump into restarting address page 43 TMP86CP27AFG 3.7 external interrupts the TMP86CP27AFG has 7 external interrupt inputs. these inputs are equipped with di gital noise reject circuits (pulse inputs of less than a certa in time are elimin ated as noise). edge selection is also possible with int1 to int3. the int0 /p63 pin can be configured as either an external inter- rupt input pin or an input/output port, and is configured as an input port during reset. edge selection, noise reject control and int0 /p63 pin function selection are performed by the external interrupt control register (eintcr). note 1: in normal1/2 or idle1/2 mode, if a signal with no noise is input on an external interrupt pin, it takes a maximum of "si g- nal establishment time + 6/fs[s]" from the input signal's edge to set the interrupt latch. note 2: when int0en = "0", il5 is not set even if a falling edge is detected on the int0 pin input. note 3: when a pin with more than one function is used as an out put and a change occurs in data or input/output status, an inter - rupt request signal is generated in a pseudo manner. in this ca se, it is necessary to perform appropriate processing such as disabling the interrupt enable flag. source pin enable conditions release edge digital noise reject int0 int0 imf ? ef5 ? int0en=1 falling edge pulses of less than 2/fc [s] are eliminated as noise. pulses of 7/fc [s ] or more are considered to be signals. in the slow or the sleep mode, pulses of less than 1/fs [s] are eliminated as noise. pulses of 3.5/fs [s] or more are consid- ered to be signals. int1 int1 imf ? ef6 = 1 falling edge or rising edge pulses of less than 15/fc or 63/fc [s] are elimi- nated as noise. pulses of 49/fc or 193/fc [s] or more are considered to be signals. in the slow or the sleep mode, pulses of less than 1/fs [s] are eliminated as noise. pulses of 3.5/fs [s] or more are considered to be signals. int2 int2 imf ? ef8 = 1 falling edge or rising edge pulses of less than 7/fc [s] are eliminated as noise. pulses of 25/fc [s] or more are considered to be signals. in the slow or the sleep mode, pulses of less than 1/fs [s] are eliminated as noise. pulses of 3.5/fs [s] or more are consid- ered to be signals. int3 int3 imf ? ef16 = 1 falling edge or rising edge pulses of less than 7/fc [s] are eliminated as noise. pulses of 25/fc [s] or more are considered to be signals. in the slow or the sleep mode, pulses of less than 1/fs [s] are eliminated as noise. pulses of 3.5/fs [s] or more are consid- ered to be signals. int5 int5 imf ? ef19 = 1 falling edge pulses of less than 2/fc [s] are eliminated as noise. pulses of 7/fc [s ] or more are considered to be signals. in the slow or the sleep mode, pulses of less than 1/fs [s] are eliminated as noise. pulses of 3.5/fs [s] or more are consid- ered to be signals. page 44 3. interrupt control circuit 3.7 external interrupts TMP86CP27AFG note 1: fc: high-frequency clock [hz], *: don?t care note 2: when the system clock frequency is switched between high and low or when the external interrupt control register (eintcr) is overwritten, the noise canceller may not operat e normally. it is recommended that external interrupts are dis- abled using the interrupt enable register (eir). note 3: the maximum time from modifying int1 nc until a noise reject time is changed is 2 6 /fc. external interrupt control register eintcr76543210 (0037h) int1nc int0en - - int3es int2es int1es (initial value: 00** 000*) int1nc noise reject time select 0: pulses of less than 63/fc [s] are eliminated as noise 1: pulses of less than 15/fc [s] are eliminated as noise r/w int0en p63/ int0 pin configuration 0: p63 input/output port 1: int0 pin (port p63 should be set to an input mode) r/w int3 es int3 edge select 0: rising edge 1: falling edge r/w int2 es int2 edge select 0: rising edge 1: falling edge r/w int1 es int1 edge select 0: rising edge 1: falling edge r/w page 45 TMP86CP27AFG 4. special function register (sfr) the TMP86CP27AFG adopts the memory mapped i/o system , and all peripheral contro l and data transfers are performed through the special function register (sfr) or the data buffer register (dbr). the sfr is mapped on address 0000h to 003fh, dbr is mapped on address 0f80h to 0fffh. this chapter shows the arrangement of the special functi on register (sfr) and data buffer register (dbr) for TMP86CP27AFG. 4.1 sfr address read write 0000h p0dr 0001h p1dr 0002h p2dr 0003h p3dr 0004h p4dr 0005h p5dr 0006h p6dr 0007h p7dr 0008h tc7dral 0009h tc7drah 000ah tc7drbl 000bh tc7drbh 000ch tc7drcl 000dh tc7drch 000eh adccr1 000fh adccr2 0010h p0cr 0011h p1cr 0012h p3outcr 0013h p4outcr 0014h p6cr1 0015h p6cr2 0016h p2prd - 0017h p3prd - 0018h tc3cr 0019h tc4cr 001ah pwreg3 001bh pwreg4 001ch ttreg3 001dh ttreg4 001eh reserved 001fh reserved 0020h adcdr2 - 0021h adcdr1 - 0022h p4prd - 0023h p5prd - 0024h p7prd - 0025h uartsr uartcr1 page 46 4. special function register (sfr) 4.1 sfr TMP86CP27AFG note 1: do not access reserved areas by the program. note 2: ? ; cannot be accessed. note 3: write-only registers and interrupt latches cannot use the read-modify-write instructions (bit manipulation instructions such as set, clr, etc. and logical operation instructions such as and, or, etc.). 0026h - uartcr2 0027h reserved 0028h lcdcr 0029h tc7cr1 002ah tc7cr2 002bh tc7cr3 002ch eire 002dh rtccr 002eh ile 002fh reserved 0030h reserved 0031h reserved 0032h reserved 0033h reserved 0034h - wdtcr1 0035h - wdtcr2 0036h tbtcr 0037h eintcr 0038h syscr1 0039h syscr2 003ah eirl 003bh eirh 003ch ill 003dh ilh 003eh reserved 003fh psw address read write page 47 TMP86CP27AFG 4.2 dbr address read write 0f80h seg1/0 0f81h seg3/2 0f82h seg5/4 0f83h seg7/6 0f84h seg9/8 0f85h seg11/10 0f86h seg13/12 0f87h seg15/14 0f88h seg17/16 0f89h seg19/18 0f8ah seg21/20 0f8bh seg23/22 0f8ch seg25/24 0f8dh seg27/26 0f8eh seg29/28 0f8fh seg31/30 0f90h seg33/32 0f91h seg35/34 0f92h seg37/36 0f93h seg39/38 0f94h reserved 0f95h reserved 0f96h reserved 0f97h reserved 0f98h reserved 0f99h reserved 0f9ah reserved 0f9bh reserved 0f9ch reserved 0f9dh reserved 0f9eh reserved 0f9fh reserved page 48 4. special function register (sfr) 4.2 dbr TMP86CP27AFG note 1: do not access reserved areas by the program. note 2: ? ; cannot be accessed. note 3: write-only registers and interrupt latches cannot use the read-modify-write instructions (bit manipulation instructions such as set, clr, etc. and logical operation instructions such as and, or, etc.). address read write 0fa0h siobr0 0fa1h siobr1 0fa2h siobr2 0fa3h siobr3 0fa4h siobr4 0fa5h siobr5 0fa6h siobr6 0fa7h siobr7 0fa8h - siocr1 0fa9h siosr siocr2 0faah - stopcr 0fabh rdbuf tdbuf 0fach p0lcr 0fadh p1lcr 0faeh p5lcr 0fafh p7lcr 0fb0h tc7drdl 0fb1h tc7drdh 0fb2h tc7drel 0fb3h tc7dreh 0fb4h tc7capal - 0fb5h tc7capah - 0fb6h tc7capbl - 0fb7h tc7capbh - 0fb8h reserved 0fb9h reserved 0fbah reserved 0fbbh mulsel 0fbch reserved 0fbdh reserved 0fbeh reserved 0fbfh reserved address read write 0fc0h reserved : : : : 0fdfh reserved address read write 0fe0h reserved : : : : 0fffh reserved page 49 TMP86CP27AFG 5. i/o ports the TMP86CP27AFG have 8 parallel i nput/output ports (55 pins) as follows. each output port contains a latch, which holds the output data. all input ports do not have latches, so the external input data should be externally held until the input data is read from outside or reading should be performed several timer before processing. figure 5-1 shows input/output timing examples. external data is read from an i/o port in the s1 state of the read cycle during execution of the read instruction. this timing cannot be recognized from outside, so that transient input such as chattering must be processed by the pro- gram. output data changes in the s2 state of the write cycle du ring execution of the instruct ion which writes to an i/o port. note: the positions of the read and write c ycles may vary, depending on the instruction. figure 5-1 input/output timing (example) primary function secondary functions port p0 8-bit i/o port lcd segment output. external interrupt, serial interface input/output and uart input/output. port p1 8-bit i/o port lcd segment output. port p2 3-bit i/o port low-frequency resonator connections, external interrupt input, stop mode release signal input. port p3 8-bit i/o port timer/counter input/output, uart input and divider output. port p4 4-bit i/o port serial interface input/output and uart output. port p5 8-bit i/o port lcd segment output. port p6 8-bit i/o port analog input, external interrupt input and stop mode release signal input. port p7 8-bit i/o port lcd segment output. data output data input new old example: ld a, (x) fetch cycle read cycle fetch cycle s0 s1 s2 s3 s0 s1 s2 s3 s0 s1 s2 s3 instruction execution cycle input strobe (a) input timing example: ld (x), a fetch cycle write cycle fetch cycle s0 s1 s2 s3 s0 s1 s2 s3 s0 s1 s2 s3 (b) output timing instruction execution cycle output strobe page 50 5. i/o ports 5.1 port p0 (p07 to p00) TMP86CP27AFG 5.1 port p0 (p07 to p00) port p0 is an 8-bit input/output port which can be configured as an input or an output in 1-bit unit. port p0 is also used as a uart input/output, an external interrupt inpu t, serial interface input/outpu t and segment output of lcd. input/output mode is specified by the p0 control register (p0cr). when used as an input port or a seco ndary function input pins (uart input, external interrupt input or serial inter- face input), the corresponding bit of p0cr and p0lcr should be cleared to ?0?. when used as an output port, the corresponding bit of p0 cr should be set to ?1?, and the respective p0lcr bit should be cleared to ?0?. when used as an uart output pin, or serial interface output pin, the corresponding bit of p0cr and the output latch (p0dr) should be set to ?1?, a nd the respective p0lcr bit should be cleared to ?0?. when used as a segment pins of lcd, the respective bit of p0lcr should be set to ?1?. during reset, the p0dr, p0cr an d p0lcr are initi alized to ?0?. when the bit of p0cr and p0lcr is ?0?, the corresponding bit data by read instruction is a terminal input data. when the bit of p0cr is ?0? and that of p0lcr is ?1?, the corresponding bit data by read instruction is always ?0?. when the bit of p0cr is ?1?, the corresponding bit data by read instruction is the value of p0dr. note: asterisk (*) indicates ?1? or ?0? either of which can be selected. table 5-1 register programming for multi-function ports function programmed value p0dr p0cr p0lcr port input, uart input, serial interface input, and external interrupt input *?0??0? port ?0? output ?0? ?1? ?0? port ?1? output, uart output and serial interface out- put ?1? ?1? ?0? lcd segment output * * ?1? table 5-2 values read from p0dr and register programming conditions values read from p0dr p0cr p0lcr ?0? ?0? terminal input data ?0? ?1? ?0? ?1? ?0? output latch contents ?1? page 51 TMP86CP27AFG note: i = 7 to 0 figure 5-2 port 0 note: the port placed in input mode reads the pin input state. t herefore, when the input and output modes are used together, the output latch contents for the port in input mode migh t be changed by executing a bi t manipulation instruction. note 1: do not change a terminal during operation. p0dr (0000h) r/w 76543210 p07 seg32 sck0 p06 seg33 so0 p05 seg34 si0 p04 seg35 int3 p03 seg36 int2 p02 seg37 int1 p01 seg38 txd0 p00 seg39 rxd0 (initial value: 0000 0000) p0lcr (0fach) (initial value: 0000 0000) p0lcr port p0/segment output control (set for each bit individually) 0:p0 input/output port or secondary function (excect for segment) 1: lcd segment output r/w p0cr (0010h) (initial value: 0000 0000) p0cr p0 port input/output control (set for each bit individually) 0: input mode 1: output mode r/w multi function register mulsel (0fbbh) 76543210 siosel uartsel (initial value: **** **00) siosel sio function pins select 0: p05(si0), p06(so0), p07(sck0) 1: p40(si1), p41(so1), p42(sck1) r/w uartsel uart function pins select 0: p01(txd0), p00(rxd0) 1: p43(txd1), p37(rxd1) stop outen p0lcri input p0lcri p0cri input p0cri p0i output latch dq lcd data output data input (p0dri) data output (p0dri) dq dq page 52 5. i/o ports 5.1 port p0 (p07 to p00) TMP86CP27AFG note 2: perform the setting terminal of a port after performing a setup by mulsel, when changing a terminal. page 53 TMP86CP27AFG 5.2 port p1 (p17 to p10) port p1 is an 8-bit input/output port which can be configured as an input or an output in 1-bit unit. port p1 is also used as a segment output of lcd. input/output mode is specified by the p1 control register (p1cr). when used as an input port, the corresponding bi t of p1cr and p1lcr should be cleared to ?0?. when used as an output port, the corresponding bit of p1 cr should be set to ?1?, and the respective p1lcr bit should be cleared to ?0?. when used as a segment pins of lcd, the respective bit of p1lcr should be set to ?1?. during reset, the output latch (p1dr), p1cr and p1lcr are initialized to ?0?. when the bit of p1cr and p1lcr is ?0?, the corresponding bit data by read instruction is a terminal input data. when the bit of p1cr is ?0? and that of p1lcr is ?1?, the corresponding bit data by read instruction is always ?0?. when the bit of p1cr is ?1?, the corresponding bit data by read instruction is the value of p1dr. note: asterisk (*) indicates ?1? or ?0? either of which can be selected. table 5-3 register programming for multi-function ports function programmed value p1dr p1cr p1lcr port input * ?0? ?0? port ?0? output ?0? ?1? ?0? port ?1? output ?1? ?1? ?0? lcd segment output * * ?1? table 5-4 values read from p1dr and register programming conditions values read from p1dr p1cr p1lcr ?0? ?0? terminal input data ?0? ?1? ?0? ?1? ?0? output latch contents ?1? page 54 5. i/o ports 5.2 port p1 (p17 to p10) TMP86CP27AFG note: i = 7 to 0 figure 5-3 port 1 note: the port placed in input mode reads the pin input state. t herefore, when the input and output modes are used together, the output latch contents for the port in input mode migh t be changed by executing a bi t manipulation instruction. p1dr (0001h) r/w 76543210 p17 seg24 p16 seg25 p15 seg26 p14 seg27 p13 seg28 p12 seg29 p11 seg30 p10 seg31 (initial value: 0000 0000) p1lcr (0fadh) (initial value: 0000 0000) p1lcr port p1/segment output control (set for each bit individually) 0: p1 input/output port 1: lcd segment output r/w p1cr (0011h) (initial value: 0000 0000) p1cr p1 port input/output control (set for each bit individually) 0: input mode 1: output mode r/w stop outen p1lcri input p1lcri p1cri input p1cri p1i output latch dq lcd data output data input (p1dri) data output (p1dri) dq dq page 55 TMP86CP27AFG 5.3 port p2 (p22 to p20) port p2 is a 3-bit input/output port. it is also used as an external interr upt, a stop mode release signal input, and low-frequency crys tal oscillator con- nection pins. when used as an input port or a secondary function pins, respective output latch (p2dr) should be set to ?1?. during reset, the p2dr is initialized to ?1?. a low-frequency crystal osci llator (32.768 khz) is connected to pins p21 (xtin) and p22 (xtout) in the dual- clock mode. in the single-clock mode, pins p21 and p22 can be used as normal input/output ports. it is recommended that pin p20 should be used as an exte rnal interrupt input, a stop mode release signal input, or an input port. if it is used as an output port, the in terrupt latch is set on the falling edge of the output pulse. p2 port output latch (p2dr) and p2 port terminal i nput (p2prd) are located on their respective address. when read the output latch data, the p2dr should be r ead and when read the termin al input data, the p2prd reg- ister should be read. if a read instruction is execute d for port p2, read data of bits 7 to 3 are unstable. figure 5-4 port 2 note: port p20 is used as stop pin. therefore, when stop mode is started, outen does not affect to p20, and p20 becomes high-z mode. p2dr (0002h) r/w 76543210 p22 xtout p21 xtin p20 int5 stop (initial value: **** *111) p2prd (0f9ch) read only p22 p21 p20 output latch osc. enable output latch dq p20 (int5, stop) dq output latch dq p21 (xtin) p22 (xtout) data input (p20prd) data input (p20) data output (p20) contorl input data input (p21prd) output latch read (p21) data output (p21) data input (p22prd) output latch read (p22) data output (p22) stop outen xten fs page 56 5. i/o ports 5.4 port p3 (p37 to p30) TMP86CP27AFG 5.4 port p3 (p37 to p30) port p3 is a 8-bit input/output port. it is also used as a timer/counter input/output or divider output. when used as a timer/counter output or divider output, respective output latch (p3dr) should be set to ?1?. it can be selected whether output circuit of port p3 is c-mos output or a sink open drain individually, by setting p3outcr. when a corresponding bit of p3 outcr is ?0?, the output circuit is selected to a sink open drain and when a corresponding bit of p3outcr is ?1?, the output circuit is selected to a c-mos output. when used as an input port or timer/counter input, respective output control (p3outcr) should be set to ?0? after p3dr is set to ?1?. when using this port as a ppg1 and/or ppg2 output, set the output latch (p3dr) and then set the p3outcr to ?1?. next, set the ppg output initial value in the ppg1ini and/ or ppg2ini, and set the ppg1oe and/or ppg2oe to ?1? to enable ppg output. at this time, the output latch (p3dr) should be set to the same value as the ppg output initial value (ppg1ini, ppg2ini). during reset, the p3dr is in itialized to ?1?, and the p3outcr is initialized to ?0?. p3 port output latch (p3dr) and p3 port terminal input (p3prd) are located on their respective address. when read the output latch data, the p3dr should be r ead and when read the termin al input data, the p3prd reg- ister should be read. note: i = 4 to 0 and 7 note: j = 6, 5 k = 2, 1 figure 5-5 port 3 data output (p3dr) control output stop outen p3outcri dq p3i p3outcri input data input (p3prd) output latch read (p3dr) control input dq output latch a) p37, p34, p33, p32, p31, p30 data output (p3dr) ppgk stop outen p3outcrj dq p3i p3outcrj data input (p3prd) data latch read (p3dr) ppgkini dq output latch b) p36, p35 a b s ppgkoe page 57 TMP86CP27AFG note 1: do not change a terminal during operation. note 2: perform the setting terminal of a port after performing a setup by mulsel, when changing a terminal. p3dr (0003h) r/w 76543210 p37 rxd1 p36 ppg2 p35 ppg1 p34 tc7 p33 emg p32 pwm4 pdo4 ppg4 tc4 p31 pwm3 pdo3 tc3 p30 dvo (initial value: 1111 1111) p3outcr (0012h) (initial value: 0000 0000) p3outcr port p3 output circuit control (set for each bit individually) 0: sink open-drain output 1: c-mos output r/w p3prd (0017h) read only p37 p36 p35 p34 p33 p32 p31 p30 multi function register mulsel (0fbbh) 76543210 siosel uartsel (initial value: **** **00) siosel sio function pins select 0: p05(si0), p06(so0), p07(sck0) 1: p40(si1), p41(so1), p42(sck1) r/w uartsel uart function pins select 0: p01(txd0), p00(rxd0) 1: p43(txd1), p37(rxd1) page 58 5. i/o ports 5.5 port p4 (p43 to p40) TMP86CP27AFG 5.5 port p4 (p43 to p40) port p4 is a 4-bit input/output port. it is also used as a uart output or serial interface input/output. when used as a uart output or serial interface output, respective output latch (p4dr) should be set to ?1?. it can be selected whether output circuit of port p4 is c-mos output or a sink open drain individually, by setting p4outcr. when a corresponding bit of p4 outcr is ?0?, the output circuit is selected to a sink open drain and when a corresponding bit of p4outcr is ?1?, the output circuit is selected to a c-mos output. when used as an input port or serial interface input, respective output cont rol (p4outcr) should be set to ?0? after p4dr is set to ?1?. during reset, the p4dr is initialized to ?1?, and the p4outcr is initialized to ?0?. p4 port output latch (p4dr) and p4 port terminal input (p4prd) are located on their respective address. when read the output latch data, the p4dr should be r ead and when read the termin al input data, the p4prd reg- ister should be read. if a read instruction is executed fo r the p4prd, p4dr and the p4outcr, read data of bits 7 to 5 are unstable. note: i = 4 to 0 figure 5-6 port 4 table 5-5 register programming for multi-function ports (p43 to p40) function programmed value p4dr p4outcr port input or timer counter input ?1? ?0? port ?0? output ?0? programming for each applica- tions port ?1? output or timer counter output ?1? data output (p4dr) control output stop outen p4outcri dq p4i p4outcri input data input (p4prd) output latch read (p4dr) control input dq output latch page 59 TMP86CP27AFG note 1: do not change a terminal during operation. note 2: perform the setting terminal of a port after performing a setup by mulsel, when changing a terminal. p4dr (0004h) r/w 76543210 p43 txd1 p42 sck1 p41 so1 p40 si1 (initial value: **** 1111) p4outcr (0013h) (initial value: **** 0000) p4outcr port p4 output circuit control (set for each bit individually) 0: sink open-drain output 1: c-mos output r/w p4prd (0022h) read only p43 p42 p41 p40 multi function register mulsel (0fbbh) 76543210 siosel uartsel (initial value: **** **00) siosel sio function pins select 0: p05(si0), p06(so0), p07(sck0) 1: p40(si1), p41(so1), p42(sck1) r/w uartsel uart function pins select 0: p01(txd0), p00(rxd0) 1: p43(txd1), p37(rxd1) page 60 5. i/o ports 5.6 port p5 (p57 to p50) TMP86CP27AFG 5.6 port p5 (p57 to p50) port p5 is an 8-bit input/output port which can be configured as an input or an output in 1-bit unit. port p5 is also used as a segment output of lcd. when used as an input port, the corresponding bit of p5lcr should be cleared to ?0?, and the respective p5dr bit should be set to ?1?. when used as an output port, the respec tive p5lcr bit should be cleared to ?0?. when used as a segment pins of lcd, the respective bit of p5lcr should be set to ?1?. during reset, the output latch (p5dr) are intial ized to ?1?, and p5lcr are initialized to ?0?. p5 port output latch (p5dr) and p5 port terminal input (p5prd) are located on their respective address. when read the output latch data, the p5dr should be r ead and when read the termin al input data, the p5prd reg- ister should be read. if the terminal input data which is configured as lcd segment output is read, unstable data is read. note: asterisk (*) indicates ?1? or ?0? either of which can be selected. note: i = 7 to 0 figure 5-7 port 5 table 5-6 register programming for multi-function ports function programmed value p5dr p5lcr port input ?1? ?0? port ?0? output ?0? ?0? lcd segment output * ?1? stop outen p5lcri p5cri input terminal input (p5prd) p5i output latch dq lcd data output output latch data (p5dri) data output (p5dr) dq page 61 TMP86CP27AFG p5dr (0005h) r/w 76543210 p57 seg16 p56 seg17 p55 seg18 p54 seg19 p53 seg20 p52 seg21 p51 seg22 p50 seg23 (initial value: 1111 1111) p5lcr (0faeh) (initial value: 0000 0000) p5lcr port p5/segment output control (set for each bit individually) 0: p5 input/output port 1: lcd segment output r/w p5prd (0023h) read only p57 p56 p55 p54 p53 p52 p51 p50 page 62 5. i/o ports 5.7 port p6 (p67 to p60) TMP86CP27AFG 5.7 port p6 (p67 to p60) port p6 is an 8-bit input/output port which can be configured as an input or an output in 1-bit unit. port p6 is also used as an analog input, key-on wakeup input and external interrupt input. input/output mode is specified by the p6 control register (p6cr1) and input control register (p6cr2). when used as an output port, the corresponding bit of p6cr1 should be set to ?1?. when used as an input port, key-on wakeup input or an external interrupt input, the corresponding bit of p6cr1 should be cleared to ?0?, and then, the corresponding bit of p6cr2 should be set to ?1?. when used as an analog input, the corresponding bit of p6cr1 should be cleared to ?0?, and then, the correspond- ing bit of p6cr2 should be cleared to ?0?. during reset, the output latch (p6dr) and p6cr1 are initialized to ?0?, p6cr2 is initialized to ?1?. when the bit of p6cr1 and p6cr2 is ?0?, the corresponding bit data by read instruction is always ?0?. when the bit of p6cr1 is ?0? and that of p6cr2 is ?1?, th e corresponding bit data by r ead instruction is a terminal input data. when the bit of p6cr1 is ?1?, the corresponding bi t data by read instruction is the value of p6dr. note: asterisk (*) indicates ?1? or ?0? either of which can be selected. table 5-7 register programming for multi-function ports function programmed value p6dr p6cr1 p6cr2 port input external interrupt input or key-on wakeup input *?0??1? analog input * ?0? ?0? port ?0? output ?0? ?1? * port ?1? output ?1? ?1? * table 5-8 values read from p6dr and register programming conditions values read from p6dr p6cr1 p6cr2 ?0? ?0? ?0? ?0? ?1? terminal input data ?1? ?0? output latch contents ?1? page 63 TMP86CP27AFG note 1: i = 1 to 3 and 7, j = 4 to 6 and 0, k = 2 to 5 note 2: stop is bit7 in syscr1. note 3: sain is ad input select signal. note 4: stopk is input select signal in a key-on wakeup. figure 5-8 port 6 note 1: the port placed in input mode reads the pin input state. therefore, when the input and output modes are used together, the output latch contents for the port in input mode might be changed by ex ecuting a bit manipulation instruction. note 2: when used as an analog inport, be sure to clear the corresponding bit of p6cr2 to disable the port input. note 3: do not set the output mode (p6cr1 = ?1?) for the pin used as an analog input pin. note 4: pins not used for analog input can be used as i/o ports. during ad conversi on, output instructions should not be executed to keep a precision. in addition, a variable signal should not be input to a port adjacent to the analog input during ad conversion. p6i dq dq p6cr2i p6cr2i input p6cr1i p6cr1i input data input (p6dri) data output (p6dri) stop outten analog input ainds sain dq control input p6i dq dq p6cr2j p6cr2j input p6cr1j p6cr1j input data output (p6drj) stop outten analog input ainds stopk key-on wakeup dq data input (p6drj) a) p67, p63, p62, p61 sain b) p66, p65, p64, p60 page 64 5. i/o ports 5.7 port p6 (p67 to p60) TMP86CP27AFG p6dr (0006h) r/w 76543210 p67 ain7 p66 ain6 stop4 p65 ain5 stop3 p64 ain4 stop2 p63 ain3 int0 p62 ain2 p61 ain1 p60 ain0 stop5 (initial value: 0000 0000) p6cr1 (0014h) 76543210 (initial value: 0000 0000) p6cr1 i/o control for port p6 (specified for each bit) 0: input mode 1: output mode r/w p6cr2 (0015h) 76543210 (initial value: 1111 1111) p6cr2 p6 port input control (specified for each bit) 0: analog input 1: port input, external interrupt input or key-on wakeup input r/w page 65 TMP86CP27AFG 5.8 port p7 (p77 to p70) port p7 is an 8-bit input/output port which can be configured as an input or an output in one-bit unit. port p7 is also used as a segment output of lcd. when used as an input port, the corresponding bit of p7lcr should be cleared to ?0?, and the respective p7dr bit should be set to ?1?. when used as an output port, the respec tive p7lcr bit should be cleared to ?0?. when used as a segment pins of lcd, the respective bit of p7lcr should be set to ?1?. during reset, the output latch (p7dr) are initia lized to ?1?, and p7lcr are initialized to ?0?. p7 port output latch (p7dr) and p7 port terminal input (p7prd) are located on their respective address. when read the output latch data, the p7dr should be r ead and when read the termin al input data, the p7prd reg- ister should be read. if the terminal input data which is configured as lcd segment output is read, unstable data is read. note: asterisk (*) indicates ?1? or ?0? either of which can be selected. note: i = 7 to 0 figure 5-9 port 7 table 5-9 register programming for multi-function ports function programmed value p7dr p7lcr port input ?1? ?0? port ?0? output ?0? ?0? lcd segment outputt * ?1? stop outen p7lcri p7cri input terminal input (p7prd) output latch dq lcd data output output latch data (p7dr) data output (p7dr) dq p7i page 66 5. i/o ports 5.8 port p7 (p77 to p70) TMP86CP27AFG p7dr (0007h) r/w 76543210 p77 seg8 p76 seg9 p75 seg10 p74 seg11 p73 seg12 p72 seg13 p71 seg14 p70 seg15 (initial value: 1111 1111) p7lcr (0fafh) (initial value: 0000 0000) p7lcr port p7/segment output control (set for each bit individually) 0: p7 input/output port 1: segment output r/w p7prd (0024h) read only p77 p76 p75 p74 p73 p72 p71 p70 (initial value: 0000 0000) page 67 TMP86CP27AFG 6. time base timer (tbt) the time base timer generates time base for key scanning, dynamic displaying, etc. it also provides a time base timer interrupt (inttbt). 6.1 time base timer 6.1.1 configuration figure 6-1 time base timer configuration 6.1.2 control time base timer is controled by time base timer control register (tbtcr). note 1: fc; high-frequency clock [hz], fs ; low-frequency clock [hz], *; don't care time base timer control register 7 6543210 tbtcr (0036h) (dvoen) (dvock) (dv7ck) tbten tbtck (initial value: 0000 0000) tbten time base timer enable / disable 0: disable 1: enable tbtck time base timer interrupt frequency select : [hz] normal1/2, idle1/2 mode slow1/2 sleep1/2 mode r/w dv7ck = 0 dv7ck = 1 000 fc/2 23 fs/2 15 fs/2 15 001 fc/2 21 fs/2 13 fs/2 13 010 fc/2 16 fs/2 8 ? 011 fc/2 14 fs/2 6 ? 100 fc/2 13 fs/2 5 ? 101 fc/2 12 fs/2 4 ? 110 fc/2 11 fs/2 3 ? 111 fc/2 9 fs/2 ? fc/2 23 or fs/2 15 fc/2 21 or fs/2 13 fc/2 16 or fs/2 8 fc/2 14 or fs/2 6 fc/2 13 or fs/2 5 fc/2 12 or fs/2 4 fc/2 11 or fs/2 3 fc/2 9 or fs/2 tbtcr tbten tbtck 3 mpx source clock falling edge detector time base timer control register inttbt interrupt request idle0, sleep0 release request page 68 6. time base timer (tbt) 6.1 time base timer TMP86CP27AFG note 2: the interrupt frequency (tbtck) must be selected with t he time base timer disabled (tbten="0"). (the interrupt fre- quency must not be changed with the disable from the enable state.) both frequency selection and enabling can be per- formed simultaneously. 6.1.3 function an inttbt ( time base timer interrupt ) is generated on the first falling edge of source clock ( the divider output of the timing generato which is selected by tbtck. ) after time base timer has been enabled. the divider is not cleared by the progra m; therefore, only the first interrupt may be generated ahead of the set interrupt period ( figure 6-2 ). figure 6-2 time base timer interrupt example :set the time base timer frequency to fc/2 16 [hz] and enable an inttbt interrupt. ld (tbtcr) , 00000010b ; tbtck 010 ld (tbtcr) , 00001010b ; tbten 1 di ; imf 0 set (eirl) . 7 table 6-1 time base timer interrupt frequency ( example : fc = 16.0 mhz, fs = 32.768 khz ) tbtck time base timer interrupt frequency [hz] normal1/2, idle1/2 mode normal1/2, idle1/2 mode slow1/2, sleep1/2 mode dv7ck = 0 dv7ck = 1 000 1.91 1 1 001 7.63 4 4 010 244.14 128 ? 011 976.56 512 ? 100 1953.13 1024 ? 101 3906.25 2048 ? 110 7812.5 4096 ? 111 31250 16384 ? source clock enable tbt interrupt period tbtcr page 69 TMP86CP27AFG 6.2 divider output ( dvo ) approximately 50% duty pulse can be output using the divider output circuit, which is useful for piezoelectric buzzer drive. divider output is from dvo pin. 6.2.1 configuration figure 6-3 divider output 6.2.2 control the divider output is controlled by the time base timer control register. note: selection of divider output frequency (dvock) must be made whil e divider output is disabled (dvoen="0"). also, in other words, when changing the state of the divider output frequen cy from enabled (dvoen="1") to disable(dvoen="0"), do not change the setting of the divider output frequency. time base timer control register 7654 321 0 tbtcr (0036h) dvoen dvock (dv7ck) (tbten) (tbtck) (initial value: 0000 0000) dvoen divider output enable / disable 0: disable 1: enable r/w dvock divider output ( dvo ) frequency selection: [hz] normal1/2, idle1/2 mode slow1/2 sleep1/2 mode r/w dv7ck = 0 dv7ck = 1 00 fc/2 13 fs/2 5 fs/2 5 01 fc/2 12 fs/2 4 fs/2 4 10 fc/2 11 fs/2 3 fs/2 3 11 fc/2 10 fs/2 2 fs/2 2 tbtcr output latch port output latch mpx dvoen tbtcr page 70 6. time base timer (tbt) 6.2 divider output (dvo) TMP86CP27AFG example :1.95 khz pulse output (fc = 16.0 mhz) ld (tbtcr) , 00000000b ; dvock "00" ld (tbtcr) , 10000000b ; dvoen "1" table 6-2 divider output frequency ( exam ple : fc = 16.0 mhz, fs = 32.768 khz ) dvock divider output frequency [hz] normal1/2, idle1/2 mode slow1/2, sleep1/2 mode dv7ck = 0 dv7ck = 1 00 1.953 k 1.024 k 1.024 k 01 3.906 k 2.048 k 2.048 k 10 7.813 k 4.096 k 4.096 k 11 15.625 k 8.192 k 8.192 k page 71 TMP86CP27AFG 7. watchdog timer (wdt) the watchdog timer is a fail-safe system to detect rapidl y the cpu malfunctions such as endless loops due to spu- rious noises or the deadlock conditions, and return the cpu to a sy stem recovery routine. the watchdog timer signal for detecting malfunctions can be programmed only once as ?reset request? or ?inter- rupt request?. upon the reset release, this signal is initialized to ?reset request?. when the watchdog timer is not used to detect malfunctions, it can be used as the timer to provide a periodic inter- rupt. note: care must be taken in system des ign since the watchdog timer functions are not be operated completely due to effect of disturbing noise. 7.1 watchdog timer configuration figure 7-1 watchdog timer configuration 0034 h overflow wdt output internal reset binary counters wdtout writing clear code writing disable code wdten wdtt 2 0035 h watchdog timer control registers wdtcr1 wdtcr2 intwdt interrupt request interrupt request reset request reset release clock clear 1 2 controller q sr s r q selector fc/2 23 or fs/2 15 fc/2 21 or fs/2 13 fc/2 19 or fs/2 11 fc/2 17 or fs/2 9 page 72 7. watchdog timer (wdt) 7.2 watchdog timer control TMP86CP27AFG 7.2 watchdog timer control the watchdog timer is controlled by the watchdog timer control registers (wdtcr1 and wdtcr2). the watch- dog timer is automatically enabled after the reset release. 7.2.1 malfunction detection me thods using the watchdog timer the cpu malfunction is detected, as shown below. 1. set the detection time, select the output, and clear the binary counter. 2. clear the binary counter repeatedly within the specified detection time. if the cpu malfunctions such as en dless loops or the deadlock condition s occur for some reason, the watch- dog timer output is activated by the binary-counter overflow unless the binary counters are cleared. when wdtcr1 page 73 TMP86CP27AFG note 1: after clearing wdtout to ?0?, the program cannot set it to ?1?. note 2: fc: high-frequency clock [hz], fs : low-frequency clock [hz], *: don?t care note 3: wdtcr1 is a write-only register and must not be used with any of read-modify-write instructions. if wdtcr1 is read, a don?t care is read. note 4: to activate the stop mode, disable the watchdog timer or clear the counter immediately before entering the stop mode. after clearing the counter, clear the counter again immediately after the stop mode is inactivated. note 5: to clear wdten, set the register in accordance wi th the procedures shown in ?1.2.3 watchdog timer disable?. note 1: the disable code is valid only when wdtcr1 page 74 7. watchdog timer (wdt) 7.2 watchdog timer control TMP86CP27AFG 7.2.3 watchdog timer disable to disable the watchdog timer, set the register in accordance with the fo llowing procedures . setting the reg- ister in other procedures causes a malfunction of the microcontroller. 1. set the interrupt master flag (imf) to ?0?. 2. set wdtcr2 to the clear code (4eh). 3. set wdtcr1 page 75 TMP86CP27AFG 7.2.5 watchdog timer reset when a binary-counter overflow occurs while wdt cr1 page 76 7. watchdog timer (wdt) 7.3 address trap TMP86CP27AFG 7.3 address trap the watchdog timer control register 1 and 2 share the a ddresses with the control regi sters to generate address traps. 7.3.1 selection of address tr ap in internal ram (atas) wdtcr1 page 77 TMP86CP27AFG 7.3.4 address trap reset while wdtcr1 page 78 7. watchdog timer (wdt) 7.3 address trap TMP86CP27AFG page 79 TMP86CP27AFG 8. 10-bit timer/counter (tc7) 8.1 configuration figure 8-1 10-bi t timer/counter 7 8.2 control timer/counter 7 is controlled by timer/counter control register 1 (tc7cr1), timer/counter control register 2 (tc7cr2), timer/counter control register 3 (tc7cr3), 10-b it dead time 1 setup register (tc7dra), pulse width 1 setup register (tc7drb), period setup register (tc7drc) , dead time 2 setup register (tc7drd), pulse width 2 setup register (tc7dre), and two capture value registers (tc7capa and tc7capb). timer/counter 7 control register 1 tc7cr1 (0029h) 76543210 trgam trgsel ppg2ini ppg1ini ncrsel tc7ck (initial value: 0000 0000) 10-bit up counter compare register e a b cy d s compare register d compare register c compare register b compare register a tc7cr1 tc7cr2 tc7capa tc7capb tc7cr3 noise canceller emergency output stop control edge detection ppg output control comparator tc7dra tc7drb tc7drc tc7drd tc7dre transfer control capture control inttc7t interrupt request fc fc/2 fc/2 2 fc/2 3 inttc7p interrupt request intemg interrupt request emergency stop tc7ck tgram start/ clear emgf csidis cstc tc7st stm cntbf trgsel emgf cstc emgie emgr ppg2oe ppg1oe tc7out csidis ncrsel tc7 pin emg pin ppg1 ppg2 ppg2ini ppg1ini ppg1ini/ ppg2ini ppg1oe/ ppg2oe tc7out page 80 8. 10-bit timer/counter (tc7) 8.2 control TMP86CP27AFG note: due to the circuit configuration, a pulse shorter than 1/fc may be eliminated as noise or accepted as a trigger. tc7ck select a source clock (supplied to the up counter). 00: fc [hz] 01: fc/2 [hz] 10 fc/2 2 [hz] 11: fc/2 3 [hz] r/w ncrsel select the duration of noise elimination for tc7 input (after passing through the flip-flop). 00: eliminate pulses shorter than 16/fc [s] as noise. 01: eliminate pulses shorter than 8/fc [s] as noise. 10: eliminate pulses shorter than 4/fc [s] as noise. 11: do not eliminate noise. (note) ppg1ini specify the initial value of ppg1 out- put. select positive or negative logic. 0: low (positive logic) 1: high (negative logic) ppg2ini specify the initial value of ppg2 out- put. 0: low (positive logic) 1: high (negative logic) trgsel select a trigger start edge. 0: start on trigger falling edge. 1: start on trigger rising edge. trgam trigger edge acceptance mode 0: always accept trigger edges. 1: do not accept trigger edges during active output. timer/counter 7 control register 2 tc7cr2 (002ah) 76543210 emgr emgie ppg2oe ppg1oe cstc tc7out (initial value: 0000 0000) tc7out select an output waveform mode. 00: ppg1/ppg2 independent output 01: ? 10: output with variable duty ratio 11: output with 50% duty ratio r/w cstc select a count start mode. 00: command start and capture mode 01: command start and trigger start mode. 10: trigger start mode 11: - ppg1oe enable/disable ppg1 output. 0: disable 1: enable ppg2oe enable/disable ppg2 output. 0: disable 1: enable emgie enable/disable input on the emg pin. 0: disable input. 1: enable input. emgr cancel the emergency output stop state. 0: - 1: cancel the emergency output stop state. (upon canceling the state, this bit is automatically cleared to 0.) timer/counter 7 control register 3 tc7cr3 (002bh) 76543210 emgf cntbf csidis stm tc7st (initial value: **00 0000) page 81 TMP86CP27AFG note 1: the tc7cr1 and tc7cr2 registers should not be rewritten afte r a timer start (when tc7st, bit0 of the tc7cr3, is set to 1). note 2: before attempting to modify the tc7cr1 or tc7cr2, clear tc7st and then check that cntbf = 0 to determine that the timer is stopped. note 3: the tc7st bit only causes the timer to start or stop; it does not indicate the current operating state of the counter. i ts value does not change automatically when counting starts or stops note 4: in command start and capture mode or command start and tr igger start mode, writing 1 to tc7st causes the timer to restart immediately. it means that rewriting any bit other than tc7st in the tc7cr3 after a command start causes the rewriting of tc7st, resulting in the timer being restarted (ppg output is started from the initial state). when tc7st is set to 1, rewriting the tc7cr3 (using a bit manipulation or ld instruction) clears the counter and restarts the timer. note 5: tc7cr2 page 82 8. 10-bit timer/counter (tc7) 8.2 control TMP86CP27AFG note 1: data registers tc7dra to tc7dre have double-stage configur ation, consisting of a data register that stores data written by an instruction and a compare register to be compared with the counter. note 2: when writing data to data registers tc7dra to tc7dre, first write the lower byte and then the upper byte. note 3: unused bits (bits 10 to 15) in the upper bytes of dat a registers tc7dra to tc7dre ar e not assigned specific register functions. these bits are always read as 0 even when a 1 is written. note 4: values read from data registers tc7dra to tc7dre may differ from the actual ppg output waveforms due to their dou- ble-stage configuration. note 5: data registers are not updated by merely modifying the output mode with tc7cr2 page 83 TMP86CP27AFG 8.3 configuring control and data registers configure control and data registers in the following order: 1. configure mode settings: tc7cr1, tc7cr2 2. configure data registers (dead time, pulse width): tc7dra, tc7drb, tc7drd, tc7dre (only those required for selected mode) 3. configure data registers (period): tc7drc 4. configure timer start/stop:tc7cr3 ? data registers have double-stage conf iguration, consisting of a data regi ster that stores data written by an instruction and a compare register to be compared with the counter. ? data stored in a data register is processed accord ing to the output mode specified in the tc7out, transferred to the compare regi ster, and then used for comp arison with th e up counter. ? data registers required for the speci fied output mode are used for data register processing and transfer to the compare register. ensure that the output mode is specified in the tc7out (bits 0 and 1 of the tc7cr2) before configuring data registers. ? writing data to the upper byte of the tc7drc causes a da ta transfer request to be issued for data in data registers tc7dra to tc7dre. if a counter matc h or clear occurs while th at request is valid, the data is transferred to the compare re gister and becomes valid for comparison. ? if a data register is written more than once within a period, the data in the data register that was set when the upper byte of the tc7drc was written is valid as data for the next period. the data in the data register written last in the first period will be valid for the period that follows the next period. figure 8-2 example c onfiguration of contro l/data registers (1) if data is rewritten more than once within a period, the data written first is valid in the next period. valid in next period execute write instruction. period (1) tc7dra tc7drb tc7drc period (2) period (3) period (4) a1 b1 c1 execute write instruction. a2 b2 c2 execute write instruction. a3 b3 c3 previous data is maintained if data is not rewritten within the period. execute write instruction. data valid in each period period (1) tc7dra tc7drb tc7drc period (2) period (3) period (4) period (5) a1 b1 c1 execute write instruction. a5 c7 a1 b1 c1 a2 b1 c2 a3 b2 c5 a5 b2 c7 a2 c2 a4 c6 a3 c5 b2 c4 c3 execute write instruction. a6 b3 c8 a7 b4 c9 a6 b3 c8 if data is rewritten more than once within a period, the data written last is valid in the period following the next period. execute more than one data write instruction. no data write page 84 8. 10-bit timer/counter (tc7) 8.4 features TMP86CP27AFG figure 8-3 example c onfiguration of contro l/data registers (2) 8.4 features 8.4.1 programmable pulse gener ator output (ppg output) the ppg1 and ppg2 pins provide ppg outputs. the output waveform mode for ppg outputs is specified with tc7cr2 page 85 TMP86CP27AFG when the value set in the tc7drc is an odd number, the ppg2 pulse width is one count longer than the ppg1 pulse width. (b) dead time tc7dra: 000h tc7dra < tc7drc/2 to specify no dead time, set the tc7dra to 000h. figure 8-4 example oper ation in 50% duty mode: command and capture start, pos itive logic, continuous output 8.4.1.2 variable duty mode (1) description with a period specified in the tc7drc and a pulse width in the tc7drb, the ppg1 pin provides a waveform having the specified pulse width while the ppg2 pin provides a waveform having a pulse width that equals (tc7drc ? tc7drb). the ppg1 output is active at the beginning of a period, remains active during the pulse width spec- ified in the tc7drb, after which it is inactive until the end of the period. the ppg2 output is inac- tive at the beginning of a period, remains inactive during the pulse width specified in the tc7drb, after which it is active until the end of the peri od, that is, during the pulse width of (tc7drc ? tc7drb). if a dead time is specified in the tc7dra, the pulse width (active duration) is shortened by the dead time. (2) register settings tc7out = ?10?, tc7dra = ?dead time?, tc7drb = ?pulse width?, tc7drc = ?period? s, 0 m s m ' s 1 m s/2 s, 0 2 13 s/2+1 s/2+m counter period dead time source clock ppg1 output m: dead time dead time (tc7dra) period (tc7drc) pulse width (tc7drc / 2) pulse width (tc7drc / 2) dead time (tc7dra) m: dead time s: period active duration active duration ppg2 output inttc7t inttc7p page 86 8. 10-bit timer/counter (tc7) 8.4 features TMP86CP27AFG (3) valid range for data register values (a) period: 002h tc7drb + tc7dra < tc7drc 400h (writing 400h to tc7drc results in 000h being read from it.) (b) pulse width: 001h tc7drb < tc7drc (c) dead time: 000h tc7dra < tc7drb, 000h tc7dra < (tc7drc ? tc7drb) (to specify no dead time, set the tc7dra to 000h.) figure 8-5 example operat ion in variable duty mode: command and capture start, positi ve logic, c ontinuous output 8.4.1.3 ppg1/ppg2 independent mode (1) description for the ppg1 output, specify the dead time in the tc7dra and pulse width in the tc7drb. for the ppg2 output, specify the dead time in the tc7drd and pulse width in the tc7dre. with a common period specified in the tc7drc, the ppg1 and ppg2 pins provide waveforms having the specified pulse widths. s, 0 m s m ' s 1m n s, 02 13 n+1 n+m counter period dead time n n ' pulse width source clock ppg1 output m: dead time dead time (tc7dra) period (tc7drc) pulse width (tc7drc ? tc7drb) pulse width (tc7drb) dead time (tc7dra) m: dead time s: period n: pulse width active duration active duration ppg2 output inttc7t inttc7p page 87 TMP86CP27AFG the ppg1 output is active at the beginning of a period, remains active during the pulse width spec- ified in the tc7drb, after which it is inactive until the end of the period. the ppg2 output is active at the beginning of a period, remains active during the pulse width spec- ified in the tc7dre, after which it is inactive until the end of the period. if a dead time is specified in the tc7dra for the ppg1 output or in the tc7drd for the ppg2 output, the pulse width (active duration) is shortened by the dead time. (2) register settings tc7out = ?00?, tc7drc = ?period? tc7dra = ?ppg1 dead time?, tc7drb = ?ppg1 pulse width? tc7drd = ?ppg2 dead time?, tc7dre = ?ppg2 pulse width? (3) valid range for data register values (a) period: 002h tc7drc 400h (writing 400h to tc7drc results in 000h being read from it.) (b) pulse width: 001h tc7drb 400h (writing 400h to tc7drb results in 000h being read from it.) 001h tc7dre 400h (writing 400h to tc7dre results in 000h being read from it.) (c) dead time: 000h tc7dra 3ffh, where tc7dra < tc7drb tc7drc 000h tc7drd 3ffh, where tc7drd < tc7dre tc7drc (to specify no dead time, write 000h.) ? settings for a duty ratio of 0% 002h tc7drc tc7dra 3ffh (ppg1 output) 002h tc7drc tc7drd 3ffh (ppg2 output) ? settings for a duty ratio greater than 0%, up to 100% 000h tc7dra < tc7drb tc7drc 400h (ppg1 output) 000h tc7drd < tc7dre tc7drc 400h (ppg2 output) period 0% duty period 100% duty page 88 8. 10-bit timer/counter (tc7) 8.4 features TMP86CP27AFG figure 8-6 example operati on in ppg1/ppg2 independent mode: command and capture start, positi ve logic, c ontinuous output 8.4.2 starting a count a count can be started by using a command or tc7 pin input. 8.4.2.1 command start and capture mode (1) description writing a 1 to tc7st causes the current count to be cleared and the counter to start counting. once the count has reached a specified period, the count er is cleared. the counter subsequently restarts counting if stm specifies continuous mode; it stops counting if stm specifies one-time mode. writing a 1 to tc7st before the count reaches a period causes the counter to be cleared, after which it operates as specified with stm. the count values at the rising and falling edges on the tc7 pin can be stored in capture registers (details for the capture are gi ven in a separate section). 0 m s m ' s 1m t us, 02 13 n counter period dead time n n ' pulse width source clock ppg1 output m: dead time ppg1 dead time (tc7dra) period (tc7drc) ppg2 pulse width (tc7dre) ppg2 dead time (tc7drd) ppg1 pulse width (tc7drb) s: period u: pulse width t: dead time n: pulse width active duration active duration ppg2 output inttc7t inttc7p t t ' dead time u u ' pulse width page 89 TMP86CP27AFG (2) register settings cstc = ?00?: command start and capture mode stm: continuous/one-time output tc7st = ?1?: starts counting figure 8-7 exampl e operation in comma nd start and capture mode 8.4.2.2 command start and trigger start mode (1) description writing a 1 to tc7st causes the current count to be cleared and the counter to start counting. the operation is the same as that in command start and capture mode if there is no trigger input on the tc7 pin. if an edge specified with the start edge selection field (trgsel) appears on the tc7 pin, however, the timer starts counting. the counter is cleared and stopped while the tc7 pin is driven to the specified clear/stop level. if the tc7 pin is at the clear/stop level when a count start command is issued (1 is written to tc7st), counting does not start (inttc7p does not occur) until a trigger start edge appears, causing inttc7t to occur (a trig ger input takes precedence over a command start). note: for more information on the acceptance of a trigger, see 8.4.2.5 ?trigger start/stop acceptance mode?. (2) register settings cstc = ?01?: command start and trigger start mode stm: continuous/one-time output tc7st = ?1?: starts counting trgsel: trigger selection figure 8-8 example operation in command st art and trigger start mode tc7st = 1 count start (command) count cleared start count cleared start count cleared restart ppg1 ppg output with a period specified with tc7drc ppg output with a period specified with tc7drc ppg output with a period specified with tc7drc count start (command) count cleared start count cleared count start ppg1 when trgsel = 0 (start on falling edge) tc7 input (signal after noise elimination) period (tc7drc) count stopped ppg output with a period specified with tc7drc if there is no trigger count stops with a trigger (high level). count starts with a trigger (falling edge). page 90 8. 10-bit timer/counter (tc7) 8.4 features TMP86CP27AFG 8.4.2.3 trigger start mode (1) description if an edge specified with the st art edge selection field (trgsel) appears on the tc7 pin, the timer starts counting. the counter is cleared and stopped wh ile the tc7 pin is driven to the specified clear/ stop level. in trigger start mode, writing a 1 to tc7st is ignored and does not initialize the ppg output. note: for more information on the acceptance of a trigger, see 8.4.2.5 ?trigger start/stop acceptance mode?. (2) register settings cstc = ?10?: trigger start mode stm: continuous/one-time output tc7st = ?1?: starts waiting for a trigger on the tc7 pin trgsel: trigger selection figure 8-9 example operat ion in trigger start mode 8.4.2.4 trigger capture mode (cstc = 00) (1) description when counting starts in command start and capture mode, the count values at the rising and falling edges of the tc7 pin input are captured and st ored in capture registers tc7capa and tc7capb, respectively. count start count stopped count stopped count start count cleared count cleared ppg1 output (example) tc7 input (signal after noise elimination) after a command is set, counting does not start until a specified trigger appears. count start count stopped count start command set command set count cleared ppg1 output (example) tc7 input (signal after noise elimination) after a command is set, counting does not start until a specified trigger appears. page 91 TMP86CP27AFG the captured data is first stored in the capture buffer. at the end of the period, the data is trans- ferred from the capture buffer to the capture register. if a trigger input does not appear within a period, the data captured in the previous period rema ins in the capture buffer and is transferred to the capture register at the end of the period. if more th an one trigger edge is detected within a period, the data captured last is written to the capture register. captured data must be read in the following order: lower byte of capture register a (tc7capal), upper byte of capture register a (tc7capah), lo wer byte of capture register b (tc7capbl), and upper byte of capture register b (tc7capbh). note that reading only the rising-edge captured data (tc7capa) does not update the next captured data. the falling-edge captured data (tc7capb) must also be read. an attempt to read a captured va lue from a register other than the upper byte of the tc7capb causes the capture registers to enter protected state, in which captured data cannot be updated. read- ing a value from the upper byte of the tc7capb can cels that state, re-enabl ing the updating of cap- tured data (the tc7capa and tc7capb ar e read as a single set of operation). note that the protected state may be still effectiv e immediately after the c ounter starts. ensure that a dummy read of capture registers is performed in the first period to cancel the protected state. the capture feature of the tc7 assumes that a capture trigger (rising or falling edge) appears within a period. captured data is updated (an edge is detected) only when the timer is operating (tc7st = 1). if a timer stop command (tc7st = 0) is written within a period, captured data will be undefined. captured data is not updated after a one -time stop command is written. in one-time stop mode, no trigger is accepted af ter a stop command is given. (2) register settings cstc = ?00?: command start and capture mode stm: continuous/one-time output tc7st = ?1?: starts counting page 92 8. 10-bit timer/counter (tc7) 8.4 features TMP86CP27AFG figure 8-10 exam ple operation in tr igger capture mode 8.4.2.5 trigger start/stop acceptance mode (1) selecting an input signal logi c for the tc7 pin (trigger input) the logic for an input trigger signal on the tc7 pin can be specified using tc7cr1 page 93 TMP86CP27AFG figure 8-11 tr igger input signal when trgsel is set to 0 to select a falling-edge trigger, a falling edge detected on the tc7 pin causes the counter to start counting and a high level on the tc7 pin causes the counter to be cleared and the ppg output to be initialized. the counter is stopped while the tc7 pin input is high. when trgsel is set to 1 to sel ect a rising-edge trigger, a rising edge detected on the tc7 pin causes the counter to start counting and a low leve l on the tc7 pin causes the counter to be cleared and the ppg output to be initialized. the counter is stopped while the tc7 pin input is low. in one-time stop mode, th e counter accepts a stop trigger but does not accept a start trigger (when a stop trigger is accepted within a period, the output is immediatel y initialized a nd the counter is stopped). all triggers (start and stop) are ignored when the timer is stopped (tc7st = 0). (2) specifying whether triggers are always accepted or ignored when ppg outputs are active the tc7cr1 page 94 8. 10-bit timer/counter (tc7) 8.4 features TMP86CP27AFG figure 8-12 start and clear /stop triggers on the tc7 pin: falling-edge trigger (counting stopped at high leve l), triggers always accepted (3) ignoring triggers when ppg outputs are active setting trgam to 1 specifies that triggers are ignored when ppg outputs are active; trigger edges detected when ppg1 and ppg2 ou tputs are inactive are accepted and cause the counter to be cleared and stopped. if a trigger is de tected when ppg1 and ppg2 outputs are active, the counter does not stop immediately but continues counting until the outputs become inactive. if the trigger signal level is a stop level when the outputs become inactive, the counter is cl eared/stopped and waits for a next start trigger. if output is enabled for both ppg 1 and ppg2, triggers ar e accepted only when both ppg1 and ppg2 outputs are inactive. figure 8-13 start tr iggers on the tc7 pin: falling-edge trigger (counting stopped at high level), tri ggers ignored when ppg outputs are active tc7 pin input ppg1 output ( positive logic) ppg2 output ( positive logic) inttc7t inttc7p counter operating counter operating counter operating counter operating counter stopped counter stopped counter stopped count started count started count started count started count cleared count cleared end of a period count cleared tc7 pin input (signal after noise elimination) igbt1 (positive logic) igbt2 (positive logic) inttc7 triggers not accepted inttcr counter operating counter operating counter operating counter stopped counter stopped a trigger detected when ppg1 and ppg2 are inactive causes the counter to stop or start. a trigger detected when ppg1 or ppg2 is active does not cause the counter to stop. a high level of the trigger input causes the counter to stop when ppg1 and ppg2 become inactive. a trigger detected when ppg1 or ppg2 is active does not cause the counter to stop or restart. page 95 TMP86CP27AFG 8.4.3 configuring how the timer stops setting tc7st to 0 causes the timer to stop with the specified output st ate according to the setting of stm. 8.4.3.1 counting stopped with the outputs initialized when stm is set to 00, the counter stops immediately with the ppg1 and ppg2 outputs initialized to the values specified wi th ppg1ini and ppg2ini. 8.4.3.2 counting stopped with the outputs maintained when stm is set to 01, the counter stops immediat ely with the curr ent ppg1 and ppg2 output states maintained. to restart the counter from the maintained state (stm = 01), set tc7st to 1. the counter is restarted with the initial output values, specified with ppg1ini and ppg2ini. 8.4.3.3 counting stopped with the outputs initialized at the end of the period when stm is set to 10, the counter continues counting until the end of the current period and then stops. if a stop trigger is detect ed before the end of the period, how ever, the counter stops immediately. tc7cr1 and tc7cr2 must not be rewritten before the counter stops completely. the cntbf flag (tc7cr3 page 96 8. 10-bit timer/counter (tc7) 8.4 features TMP86CP27AFG figure 8-14 immedi ately stopping and clearing the count er with the ou tputs initialized (stm = 00) figure 8-15 immediately st opping and clearing the counter with the outputs maintained (stm = 01) figure 8-16 stopping th e counter at the end of the period (stm = 10) figure 8-17 stopping the counter at the end of the period (stm = 10): tc7st = 1, one-time output mode count started tc7st = 1 stm = 00 output enabled ppg1e/ppg2e = 1 stop command tc7st = 0 the counter is forcibly stopped and cleared, with the outputs initialized. ppg1 (positive logic) ppg1ini = 0 ppg2 (negative logic) ppg1ini = 1 count started tc7st = 1 stm = 01 output enabled ppg1e/ppg2e = 1 stop command tc7st = 0 the counter is forcibly stopped and cleared, with the outputs maintained. ppg1 (positive logic) ppg1ini = 0 ppg2 (negative logic) ppg1ini = 1 count started tc7st = 1 stm = 00 or 01 1 period 1 period count stopped output enabled ppg1e/ppg2e = 1 stop command tc7st = 0 stm = 10 after a stop command is executed, the counter continues counting until the end of the period. it stops at the end of the period. ppg1 (positive logic) ppg1ini = 0 ppg2 (negative logic) ppg1ini = 1 count started tc7st = 1 stm = 10 1 period output enabled ppg1e/ppg2e = 1 count stopped at the end of the period the counter stops at the end of the period and then waits for a command start or a start trigger. ppg1 (positive logic) ppg1ini = 0 ppg2 (negative logic) ppg1ini = 1 page 97 TMP86CP27AFG 8.4.5 ppg output control (initial value/output logi c, enabling/disabling output) 8.4.5.1 specifying initial values and output logic for ppg outputs the ppg1ini and ppg2ini bits (tc7cr1 page 98 8. 10-bit timer/counter (tc7) 8.4 features TMP86CP27AFG figure 8-19 noise canceller operation ? when ncrsel = 00, a tc7 input level after passing th rough the f/f is always canceled if its duration is 16/fc [s] or less and always assumed as a signal if its duration is 20/fc [s] or greater. after the input signal supplied on the tc7 pin passes through the f/f, there is a delay between 21/fc [s] and 24/fc [s] before the ppg outputs vary. ? when ncrsel = 01, a tc7 input level after passing th rough the f/f is always canceled if its duration is 8/fc [s] or less and always assumed as a signal if its duration is 10/fc [s] or greater. after the input signal supplied on the tc7 pin passes through the f/f, there is a delay between 13/fc [s] and 14/fc [s] before the ppg outputs vary. ? when ncrsel = 10, a tc7 input level after passing th rough the f/f is always canceled if its duration is 4/fc [s] or less and always assumed as a signal if its duration is 5/fc [s] or greater. after the input sig- nal supplied on the tc7 pin passes through the f/f, there is a delay of 5/fc [s] before the ppg outputs vary. ? when ncrsel = 11, a pulse shorter than 1/fc may be assumed as a signal or canceled as noise in the first-stage f/f. ensure that input signal pulses are longer than 1/fc. after the input signal supplied on the tc7 pin passes through the f/f, there is a delay of 4/fc [s] before the ppg outputs vary. table 8-1 noise canceller settings ncrsel sampling frequency (number of samplings) pulse width always assumed as nois e pulse width always assumed as signal at 8 mhz at 16 mhz at 8 mhz at 16 mhz 00 fc/4 (5) 16/fc [s] 2 [ms] 1 [ms] 20/fc [s] 2.5 [ms] 1.25 [ms] 01 fc/2 (5) 8/fc [s] 1 [ms] 500 [ns] 10/fc [s] 1.25 [ms] 0.625 [ms] 10 fc (5) 4/fc [s] 0.5 [ms] 250 [ns] 5/fc [s] 0.625 [ms] 0.3125 [ms] 11 (none) none ? ? (1/fc) fc fc/2 a fter noise elimination fc/4 when ncrsel = 00 when ncrsel = 01 when ncrsel = 10 pulses of 5/fc or longer are assumed as a signal. pulses of 10/fc or longer are assumed as a signal. pulses of 20/fc or longer are assumed as a signal. pulses of 4/fc or shorter are canceled. pulses of 8/fc or shorter are canceled. pulses of 16/fc or shorter are canceled. tc7 pin input (after passing through f/f) 1 2 3 4 5 1 2 3 4 5 1 2 3 4 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 b a z s a b z c noise canceller edge detection ppg output control circuit f/f tc7 input fc ppg output sampling clock fc fc/2 fc/4 ncrsel ncrsel = 11 page 99 TMP86CP27AFG note 1: if the pin input level changes while the specified noi se elimination threshold is being modified, the noise canceller may assume noise as a pul se or cancel a pulse as noise. note 2: if noise occurs in synchronization with the inter nal sampling timing consecutiv ely, it may be assumed as a signal. note 3: the signal supplied on the tc7 pin require s 1/fc [s] or less to pass through the f/f. 8.4.7 interrupts the tc7 supports three interrupt sources. 8.4.7.1 inttc7t (trigger start interrupt) a trigger interrupt (inttc7t) occurs when the counter star ts upon the detection of a trigger edge spec- ified with tc7cr1 page 100 8. 10-bit timer/counter (tc7) 8.4 features TMP86CP27AFG if a command start is specified (1 is written in tc7st) when the tc7 pin is at a stop level, the counter does not start (inttc7p does not occur); a subsequent trigger start edge causes the counter to start and inttc7t to occur. 8.4.7.3 intemg (emergency output stop interrupt) an emergency output stop interrupt (intemg) occurs when the emergency output stop circuit operates to stop ppg outputs in emergency. 8.4.8 emergency ppg output stop feature setting tc7cr2 page 101 TMP86CP27AFG 8.4.8.3 emg interrupt an emg interrupt (intemg) occurs when an emergency ppg out put stop input is accepted. to use an intemg interrupt for some processing, ensure that the interrupt is enabled beforehand. when the emg pin is low with emgie set to 1 ( emg pin input enabled), an at tempt to cancel the emer- gency ppg output stop state results in an interrupt being generated again, with the emergency ppg output stop state reestablished. an intemg interrupt occurs when ever a stop input is accepted when emgie = 1, regardless of whether the timer is operating. 8.4.8.4 canceling the emergency ppg output stop state to cancel the emergency ppg output stop state, en sure that the input on the emg pin is high, set tc7cr3 page 102 8. 10-bit timer/counter (tc7) 8.4 features TMP86CP27AFG figure 8-23 timing between emg pin input being detected and ppg outputs being dis- abled 8.4.9 tc7 operation and mi crocontroller operating mode the tc7 operates when the microcontroller is pl aced in normal1, normal2, idle1, or idle2 mode. if the mode changes from normal or idle to stop, sl ow, or sleep while the tc7 is operating, the tc7 is initialized and stops operating. to change the microcontroller operating mode from normal or idle to stop, slow, or sleep, ensure that the tc7 timer is stopped before attempting to execute a mode change instruction. to change the mode from stop, slow, or sleep to normal to restart the tc7, reconfigure all registers according to the appropriate tc7 operation procedure. ppg pin output emg pin input emgie 10/fc [s] 1.25 s (at 8 mhz) tc7st stm emgf ( state monitor ) emg interrupt specified with an instruction emergency stop input output initialized forcibly initial output state emergency stop input share port in input mode emgr = 1, protection feature enabled intemg (emg interrupt) emgf = 1, emergency output stop state emergency output stop state tc7st = 1, timer operating stm = 01, timer operating (continuous mode) emgr = 1, cancel emergency output stop state stm = 00 tg7st = 0 page 103 TMP86CP27AFG 9. 8-bit timercounter (tc3, tc4) 9.1 configuration figure 9-1 8-bit timercouter 3, 4 8-bit up-counter decode en a y b s a b y c d e f g h s a y b s s a y b toggle q set clear 8-bit up-counter a b y c d e f g h s decode en toggle q set clear pwm mode pdo, ppg mode pdo mode pwm, ppg mode pwm mode pwm mode 16-bit mode 16-bit mode 16-bit mode 16-bit mode timer, event counter mode overflow overflow timer, event couter mode 16-bit mode clear clear fc/2 7 fc/2 5 fc/2 3 fc/2 fc fc/2 7 fc/2 5 fc/2 3 fc/2 fc pdo, pwm, ppg mode pdo, pwm mode 16-bit mode fc/2 11 or fs/2 3 fc/2 11 or fs/2 3 fs fs tc4cr tc3cr ttreg4 pwreg4 ttreg3 pwreg3 tc3 pin tc4 pin tc4s tc3s inttc3 interrupt request inttc4 interrupt request tff4 tff3 pdo 4/pwm 4/ ppg 4 pin pdo 3/pwm 3/ pin tc3ck tc4ck tc3m tc3s tff3 tc4m tc4s tff4 timer f/f4 timer f/f3 page 104 9. 8-bit timercounter (tc3, tc4) 9.1 configuration TMP86CP27AFG 9.2 timercounter control the timercounter 3 is controlled by the timercounter 3 control register (tc3cr) and two 8-bit timer registers (ttreg3, pwreg3). note 1: do not change the timer register (t treg3) setting while the timer is running. note 2: do not change the timer register (pwreg3) setting in the operating mode except the 8-bit and 16-bit pwm modes while the timer is running. note 1: fc: high-frequency clock [hz] fs: low-frequency clock[hz] note 2: do not change the tc3m, tc3ck and tff3 settings while the timer is running. note 3: to stop the timer operation (tc3s= 1 0), do not change the tc3m, tc3ck and tff3 settings. to start the timer opera- tion (tc3s= 0 1), tc3m, tc3ck and tff3 can be programmed. note 4: to use the timercounter in the 16-bit mode, set th e operating mode by programming tc4cr page 105 TMP86CP27AFG note 7: the timer register settings are limited depending on the timer operating mode. for the detailed descriptions, see table 9- 3. note 8: the operating clock fc in t he slow or sleep mode can be used only as the high-frequency warm-up mode. page 106 9. 8-bit timercounter (tc3, tc4) 9.1 configuration TMP86CP27AFG the timercounter 4 is controlled by the timercounter 4 control register (tc4cr) and two 8-bit timer registers (ttreg4 and pwreg4). note 1: do not change the timer register (t treg4) setting while the timer is running. note 2: do not change the timer register (pwreg4) setting in the operating mode except the 8-bit and 16-bit pwm modes while the timer is running. note 1: fc: high-frequency clock [hz] fs: low-frequency clock [hz] note 2: do not change the tc4m, tc4ck and tff4 settings while the timer is running. note 3: to stop the timer operation (tc4s= 1 0), do not change the tc4m, tc4ck and tff4 settings. to start the timer operation (tc4s= 0 1), tc4m, tc4ck and tff4 can be programmed. note 4: when tc4m= 1** (upper byte in the 16-bit mode), the sour ce clock becomes the tc4 over flow signal regardless of the tc3ck setting. note 5: to use the timercounter in the 16-bit mode, select the operating mode by programming tc4m, where tc3cr page 107 TMP86CP27AFG note 6: to the timercounter in the 16-bit mode, select the so urce clock by programming tc3cr page 108 9. 8-bit timercounter (tc3, tc4) 9.1 configuration TMP86CP27AFG note: n = 3 to 4 table 9-3 constraints on register values being compared operating mode register value 8-bit timer/event counter 1 (ttregn) 255 8-bit pdo 1 (ttregn) 255 8-bit pwm 2 (pwregn) 254 16-bit timer/event counter 1 (ttreg4, 3) 65535 warm-up counter 256 (ttreg4, 3) 65535 16-bit pwm 2 (pwreg4, 3) 65534 16-bit ppg 1 (pwreg4, 3) < (ttreg4, 3) 65535 and (pwreg4, 3) + 1 < (ttreg4, 3) page 109 TMP86CP27AFG 9.3 function the timercounter 3 and 4 have the 8-bit timer, 8-bit ev ent counter, 8-bit programmable divider output (pdo), 8- bit pulse width modulation (pwm) output modes. the time rcounter 3 and 4 (tc3, 4) are cascadable to form a 16- bit timer. the 16-bit timer has the operat ing modes such as the 16-bit timer, 16-bit event counter, warm-up counter, 16-bit pulse width modulation (pwm) output and 16-bit programmable pulse generation (ppg) modes. 9.3.1 8-bit timer mode (tc3 and 4) in the timer mode, the up-counter counts up using the internal clock. when a match between the up-counter and the timer register j (ttregj) value is detected, an inttcj interrupt is generated and the up-counter is cleared. after being cl eared, the up-counter restarts counting. note 1: in the timer mode, fix tcjcr page 110 9. 8-bit timercounter (tc3, tc4) 9.1 configuration TMP86CP27AFG figure 9-2 8-bit timer mode timing chart (tc4) 9.3.2 8-bit event counter mode (tc3, 4) in the 8-bit event counter mode, the up-counter counts up at the falling edge of the input pulse to the tcj pin. when a match between the up-counter and the ttregj valu e is detected, an inttcj interrupt is generated and the up-counter is cleared. after being cleared, the up-counter restarts counti ng at the falling edge of the input pulse to the tcj pin. two machine cycles are required for the low- or high-level pulse input to the tcj pin. therefore, a maximum freque ncy to be supplied is fc/2 4 hz in the normal1/2 or idle1/2 mode, and fs/2 4 hz in the slow1/2 or sleep1/2 mode. note 1: in the event counter mode, fix tcjcr page 111 TMP86CP27AFG note 1: in the programmable divider output mode, do not change the ttregj setting while the timer is running. since ttregj is not in the shift register configur ation in the programmable divider output mode, the new value programmed in ttregj is in effect immediatel y after programming. therefore, if ttregi is changed while the timer is running, an ex pected operation may not be obtained. note 2: when the timer is stopped during pdo output, the pdoj pin holds the output status when the timer is stopped. to change the output status, program tcjcr page 112 9. 8-bit timercounter (tc3, tc4) 9.1 configuration TMP86CP27AFG figure 9-4 8-bit pdo mode timing chart (tc4) 12 0 n 0 n 0 n 0 n 0 1 2 2 1 2 1 2 3 1 0 n ? internal source clock counter match detect match detect match detect match detect held at the level when the timer is stopped set f/f write of "1" tc4cr page 113 TMP86CP27AFG 9.3.4 8-bit pulse wi dth modulation (pwm) output mode (tc3, 4) this mode is used to generate a pulse-width modulated (pwm) signals with up to 8 bits of resolution. the up-counter counts up using the internal clock. when a match between the up-counter and the pwregj value is detected, the logic level output from the timer f/fj is switched to the opposite state. the counter continues counting. the logic level output from the timer f/fj is switched to the opposite state again by the up-co unter overflow, and the counter is cleared. the inttcj interrupt request is generated at this time. since the initial value can be set to the timer f/fj by tcjcr page 114 9. 8-bit timercounter (tc3, tc4) 9.1 configuration TMP86CP27AFG figure 9-5 8-bit pwm mo de timing chart (tc4) 1 0 n n+1 ff 0 n n+1 ff 0 1 m m+1 ff 0 1 1 p n ? internal source clock counter write to pwreg4 write to pwreg4 m p m p n ? shift registar shift shift shift shift match detect match detect one cycle period match detect match detect n m p n tc4cr page 115 TMP86CP27AFG 9.3.5 16-bit timer mode (tc3 and 4) in the timer mode, the up-counter counts up using the internal clock. the timercounter 3 and 4 are cascad- able to form a 16-bit timer. when a match between the up-counter and the timer regi ster (ttreg3, ttreg4) valu e is detected after the timer is started by setting tc4cr page 116 9. 8-bit timercounter (tc3, tc4) 9.1 configuration TMP86CP27AFG 9.3.6 16-bit event c ounter mode (tc3 and 4) 9.3.7 16-bit pulse width modulatio n (pwm) output mode (tc3 and 4) this mode is used to generate a pulse-width modulated (pwm) signals with up to 16 bits of resolution. the timercounter 3 and 4 are cascadable to form the 16-bit pwm signal generator. the counter counts up using the internal clock or external clock. when a match between the up-counter and the timer register (pwreg3, pwreg4) value is detected, the logic level output from the timer f/f4 is switched to the opposite state. the counter continues counting. the logic level output from the timer f/f4 is switched to the opposite state again by the counter overflow, and the counter is cleared. the inttc4 interrupt is generated at this time. two machine cycles are required for the high- or low-level pulse input to the tc3 pin. therefore, a maxi- mum frequency to be supplied is fc/2 4 hz in the normal1 or idle1 mode, and fs/2 4 to in the slow1/2 or sleep1/2 mode. since the initial value can be set to the timer f/f4 by tc4cr page 117 TMP86CP27AFG clr (tc4cr).3: stops the timer. clr (tc4cr).7 : sets the pwm 4 pin to the high level. note 3: to enter the stop mode, stop the timer and then enter the stop mode. if the stop mode is entered with- out stopping of the timer when fc, fc/2 or fs is select ed as the source clock, a pulse is output from the pwm 4 pin during the warm-up period time after exiting the stop mode. table 9-7 16-bit pwm output mode source clock resolution repeated cycle normal1/2, idle1/2 mode slow1/2, sleep1/2 mode fc = 16 mhz fs = 32.768 khz fc = 16 mhz fs = 32.768 khz dv7ck = 0 dv7ck = 1 fc/2 11 fs/2 3 [hz] fs/2 3 [hz] 128 s244.14 s 8.39 s 16 s fc/2 7 fc/2 7 ?8 s ? 524.3 ms ? fc/2 5 fc/2 5 ?2 s ? 131.1 ms ? fc/2 3 fc/2 3 ? 500ns ? 32.8 ms ? fs fs fs 30.5 s30.5 s2 s 2 s fc/2 fc/2 ? 125 ns ? 8.2 ms ? fc fc ? 62.5 ns ? 4.1 ms ? example :generating a pulse with 1-ms high-level width and a period of 32.768 ms (fc = 16.0 mhz) setting ports ldw (pwreg3), 07d0h : sets the pulse width. ld (tc3cr), 33h : sets the operating clock to fc/2 3 , and 16-bit pwm output mode (lower byte). ld (tc4cr), 056h : sets tff4 to the initial value 0, and 16-bit pwm signal generation mode (upper byte). ld (tc4cr), 05eh : starts the timer. page 118 9. 8-bit timercounter (tc3, tc4) 9.1 configuration TMP86CP27AFG figure 9-7 16-bit pwm m ode timing chart (tc3 and tc4) 1 0 an an+1 ffff 0 an an+1 ffff 0 1 bm bm+1 ffff 0 bm cp b c 1 1 cp n a an ? ? ? internal source clock 16-bit shift register shift shift shift shift counter match detect match detect one cycle period match detect match detect an bm cp an m p tc4cr page 119 TMP86CP27AFG 9.3.8 16-bit programmable pulse generate (ppg) ou tput mode (tc3 and 4) this mode is used to generate pulses with up to 16- bits of resolution. the timer counter 3 and 4 are cascad- able to enter the 16-bit ppg mode. the counter counts up using the inte rnal clock or external clock. when a match between the up-counter and the timer register (pwreg3, pwreg4 ) value is detected, the logic level output from the timer f/f4 is switched to the opposite state. the counter continues counting. the logic level output from the timer f/f4 is switched to the opposite state again when a match betw een the up-counter and th e timer register (ttreg3, ttreg4) value is detected, and the counter is cleared. the inttc4 interrupt is generated at this time. since the initial value can be set to the timer f/f4 by tc4cr page 120 9. 8-bit timercounter (tc3, tc4) 9.1 configuration TMP86CP27AFG figure 9-8 16-bit ppg mode timing chart (tc3 and tc40) 1 0 mn mn+1 qr-1 mn qr-1 1 mn mn+1 mn+1 0 qr 0 qr 1 0 internal source clock counter write of "0" match detect match detect match detect mn mn mn match detect match detect ? n m ? ? r q ? held at the level when the timer stops f/f clear tc4cr page 121 TMP86CP27AFG 9.3.9 warm-up counter mode in this mode, the warm-up period time is obtained to assure oscillation stability when the system clocking is switched between the high-frequency and low-frequency. the timer counter 3 and 4 are cascadable to form a 16-bit timercouter. the warm-up counter mode has two types of mode; switching from the high-frequency to low-frequency, and vice-versa. note 1: in the warm-up counter mode, fi x tcicr page 122 9. 8-bit timercounter (tc3, tc4) 9.1 configuration TMP86CP27AFG 9.3.9.2 high-frequency warm-up counter mode (slow1 slow2 normal2 normal1) in this mode, the warm-up period time from a stop of the high-frequency clock fc to the oscillation sta- bility is obtained. before starting the timer, set sy scr2 page 123 TMP86CP27AFG 10. real-time clock the TMP86CP27AFG include a real time counter (rtc). a low-frequency cl ock can be used to provide a peri- odic interrupt (0.0625[s],0.125[s],0.25[s] ,0.50[s]) at a programmed interval, implement the clock function. the rtc can be used in the mode in which the low-frequenc y oscillator is active (except for the sleep0 mode). 10.1 configuration figure 10-1 confi guration of the rtc 10.2 control of the rtc the rtc is controlled by the rtc control register (rtccr). note 1: program the rtccr during low-freque ncy oscillation (when syscr2 page 124 10. real-time clock 10.3 function TMP86CP27AFG 10.3 function the rtc counts up on the internal low-frequency clock. when rtccr page 125 TMP86CP27AFG 11. asynchronous serial interface (uart ) 11.1 configuration figure 11-1 uart (asynch ronous serial interface) counter y a b c s s a b c d y e f g h uart status register uart control register 2 multi function register uart control register 1 transmit data buffer receive data buffer fc/13 fc/26 fc/52 fc/104 fc/208 fc/416 fc/96 stop bit parity bit fc/2 6 fc/2 7 fc/2 8 rxd0 rxd1 txd0 txd1 baud rate generator transmit/receive clock 2 4 3 2 2 2 noise rejection circuit mulsel shift register shift register transmit control circuit receive control circuit m p x m p x m p x mpx: multiplexer uartcr1 tdbuf rdbuf inttxd intrxd uartsr uartcr2 inttc3 page 126 11. asynchronous serial interface (uart ) 11.2 control TMP86CP27AFG 11.2 control uart is controlled by the uart control registers (uartcr1, uartcr2). the operating status can be moni- tored using the uart status register (uartsr). txd pin and rxd pin can be selected a port assignment by multi function register (mulsel). note 1: when operations are disabled by se tting txe and rxe bit to ?0?, the setting be comes valid when data transmit or receive complete. when the transmit data is stored in the transmit data buf fer, the data are not transmitted. even if data transmit is enabled, until new data are written to the transmit data buffer, the current data are not transmitted. note 2: the transmit clock and the parity are common to transmit and receive. note 3: uartcr1 page 127 TMP86CP27AFG note: when an inttxd is generated, tbep flag is set to "1" automatically. note 1: do not change mulsel page 128 11. asynchronous serial interface (uart ) 11.3 transfer data format TMP86CP27AFG 11.3 transfer data format in uart, an one-bit start bit (low level), stop bit (bit length selectable at high level, by uartcr1 ; even- or odd-number ed parity by uartcr1 |